-
Notifications
You must be signed in to change notification settings - Fork 7
Fallback on non-universal libraries when getting path for weak-node-api framework
#303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kraenhansen
merged 1 commit into
main
from
kh/ferric-fallback-on-non-universal-libraries
Nov 2, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,22 +19,46 @@ import { | |||||
| isThirdTierTarget, | ||||||
| } from "./targets.js"; | ||||||
|
|
||||||
| const APPLE_XCFRAMEWORK_CHILDS_PER_TARGET: Record<AppleTargetName, string> = { | ||||||
| "aarch64-apple-darwin": "macos-arm64_x86_64", // Universal | ||||||
| "x86_64-apple-darwin": "macos-arm64_x86_64", // Universal | ||||||
| /** | ||||||
| * A per apple target mapping to a list of xcframework slices in order of priority | ||||||
| */ | ||||||
| const APPLE_XCFRAMEWORK_SLICES_PER_TARGET: Record<AppleTargetName, string[]> = { | ||||||
| "aarch64-apple-darwin": [ | ||||||
| "macos-arm64_x86_64", // Universal | ||||||
| "macos-arm64", | ||||||
| ], | ||||||
| "x86_64-apple-darwin": [ | ||||||
| "macos-arm64_x86_64", // Universal | ||||||
| "macos-x86_64", | ||||||
| ], | ||||||
|
|
||||||
| "aarch64-apple-ios": "ios-arm64", | ||||||
| "aarch64-apple-ios-sim": "ios-arm64_x86_64-simulator", // Universal | ||||||
| "x86_64-apple-ios": "ios-arm64_x86_64-simulator", // Universal | ||||||
| "aarch64-apple-ios": ["ios-arm64"], | ||||||
| "aarch64-apple-ios-sim": [ | ||||||
| "ios-arm64_x86_64-simulator", // Universal | ||||||
| "ios-arm64-simulator", | ||||||
| ], | ||||||
| "x86_64-apple-ios": [ | ||||||
| "ios-arm64_x86_64-simulator", // Universal | ||||||
| "ios-x86_64-simulator", | ||||||
| ], | ||||||
|
|
||||||
| "aarch64-apple-visionos": "xros-arm64", | ||||||
| "aarch64-apple-visionos-sim": "xros-arm64_x86_64-simulator", // Universal | ||||||
| "aarch64-apple-visionos": ["xros-arm64"], | ||||||
| "aarch64-apple-visionos-sim": [ | ||||||
| "xros-arm64_x86_64-simulator", // Universal | ||||||
| "xros-arm64-simulator", | ||||||
| ], | ||||||
| // The x86_64 target for vision simulator isn't supported | ||||||
| // see https://doc.rust-lang.org/rustc/platform-support.html | ||||||
|
|
||||||
| "aarch64-apple-tvos": "tvos-arm64", | ||||||
| "aarch64-apple-tvos-sim": "tvos-arm64_x86_64-simulator", | ||||||
| "x86_64-apple-tvos": "tvos-arm64_x86_64-simulator", | ||||||
| "aarch64-apple-tvos": ["tvos-arm64"], | ||||||
| "aarch64-apple-tvos-sim": [ | ||||||
| "tvos-arm64_x86_64-simulator", // Universal | ||||||
| "tvos-arm64-simulator", | ||||||
| ], | ||||||
| "x86_64-apple-tvos": [ | ||||||
| "tvos-arm64_x86_64-simulator", // Universal | ||||||
| "tvos-x86_64-simulator", | ||||||
| ], | ||||||
|
|
||||||
| // "aarch64-apple-ios-macabi": "", // Catalyst | ||||||
| // "x86_64-apple-ios-macabi": "ios-x86_64-simulator", | ||||||
|
|
@@ -145,11 +169,19 @@ export function getTargetAndroidPlatform(target: AndroidTargetName) { | |||||
| } | ||||||
|
|
||||||
| export function getWeakNodeApiFrameworkPath(target: AppleTargetName) { | ||||||
| return joinPathAndAssertExistence( | ||||||
| const xcframeworkPath = joinPathAndAssertExistence( | ||||||
| weakNodeApiPath, | ||||||
| "weak-node-api.xcframework", | ||||||
| APPLE_XCFRAMEWORK_CHILDS_PER_TARGET[target], | ||||||
| ); | ||||||
| const result = APPLE_XCFRAMEWORK_SLICES_PER_TARGET[target].find((slice) => { | ||||||
| const candidatePath = path.join(xcframeworkPath, slice); | ||||||
| return fs.existsSync(candidatePath); | ||||||
| }); | ||||||
| assert( | ||||||
| result, | ||||||
| `No matching slice found in weak-node-api.xcframework for target ${target}`, | ||||||
|
||||||
| `No matching slice found in weak-node-api.xcframework for target ${target}`, | |
| `No matching slice found in weak-node-api.xcframework for target ${target}. Searched slices: ${APPLE_XCFRAMEWORK_SLICES_PER_TARGET[target].join(', ')}`, |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
fs.existsSynccall inside thefindloop could be inefficient if there are many slices to check. Consider usingfs.promises.accesswith proper error handling for better performance, or at minimum add early termination if the first slice is found.