@@ -146,53 +146,66 @@ cmake_build macos-cli
146146
147147fi
148148
149+ # Due to inconvenient design choices on both sides, we have to choose between
150+ # either long flags or short flags based on whether we're calling
151+ # `xcodebuild -create-xcframework` or `scripts/build_xcframework.mts`.
152+ if [[ " $TARGET_ENGINE " == " none" ]]; then
153+ # Node.js parseArgs() supports short flags, but only if they're single-letter.
154+ FRAMEWORK_FLAG=" --framework"
155+ DSYM_FLAG=" --debug-symbols"
156+ else
157+ # xcodebuild doesn't implement any single-letter short flags like -f and -d.
158+ FRAMEWORK_FLAG=" -framework"
159+ DSYM_FLAG=" -debug-symbols"
160+ fi
161+
149162XCFRAMEWORKS=()
150163if $BUILD_CATALYST ; then
151- XCFRAMEWORKS+=( --framework " $DIST /intermediates/catalyst/$CONFIG_BUILD -maccatalyst/NativeScript.framework"
152- --debug-symbols " $DIST /intermediates/catalyst/ $CONFIG_BUILD -maccatalyst/NativeScript.framework .dSYM" )
164+ FRAMEWORK= " $DIST /intermediates/catalyst/$CONFIG_BUILD -maccatalyst/NativeScript.framework"
165+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
153166fi
154167
155168if $BUILD_SIMULATOR ; then
156- XCFRAMEWORKS+=( --framework " $DIST /intermediates/ios-sim/$CONFIG_BUILD -iphonesimulator/NativeScript.framework"
157- --debug-symbols " $DIST /intermediates/ios-sim/ $CONFIG_BUILD -iphonesimulator/NativeScript.framework .dSYM" )
169+ FRAMEWORK= " $DIST /intermediates/ios-sim/$CONFIG_BUILD -iphonesimulator/NativeScript.framework"
170+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
158171fi
159172
160173if $BUILD_IPHONE ; then
161- XCFRAMEWORKS+=( --framework " $DIST /intermediates/ios/$CONFIG_BUILD -iphoneos/NativeScript.framework"
162- --debug-symbols " $DIST /intermediates/ios/ $CONFIG_BUILD -iphoneos/NativeScript.framework .dSYM" )
174+ FRAMEWORK= " $DIST /intermediates/ios/$CONFIG_BUILD -iphoneos/NativeScript.framework"
175+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
163176fi
164177
165178if $BUILD_MACOS ; then
166- XCFRAMEWORKS+=( --framework " $DIST /intermediates/macos/$CONFIG_BUILD /NativeScript.framework"
167- --debug-symbols " $DIST /intermediates/macos/ $CONFIG_BUILD /NativeScript.framework .dSYM" )
179+ FRAMEWORK= " $DIST /intermediates/macos/$CONFIG_BUILD /NativeScript.framework"
180+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
168181fi
169182
170183if $BUILD_VISION ; then
171- XCFRAMEWORKS+=( --framework " $DIST /intermediates/visionos/$CONFIG_BUILD -xros/NativeScript.framework"
172- --debug-symbols " $DIST /intermediates/visionos/ $CONFIG_BUILD -xros/NativeScript.framework .dSYM" )
184+ FRAMEWORK= " $DIST /intermediates/visionos/$CONFIG_BUILD -xros/NativeScript.framework"
185+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
173186
174- XCFRAMEWORKS+=( --framework " $DIST /intermediates/visionos-sim/$CONFIG_BUILD -xros/NativeScript.framework"
175- --debug-symbols " $DIST /intermediates/visionos-sim/ $CONFIG_BUILD -xros/NativeScript.framework .dSYM" )
187+ FRAMEWORK= " $DIST /intermediates/visionos-sim/$CONFIG_BUILD -xros/NativeScript.framework"
188+ XCFRAMEWORKS+=( " $FRAMEWORK_FLAG " " $FRAMEWORK " " $DSYM_FLAG " " $FRAMEWORK .dSYM" )
176189fi
177190
178191if [[ -n " ${XCFRAMEWORKS[@]} " ]]; then
179192
180- checkpoint " Creating the XCFramework (NativeScript.apple.node) "
181-
182- # This script used to output to "$DIST/ NativeScript.xcframework".
183- #
184- # We now follow the react-native-node-api prebuilds standard, emitting an
185- # XCFramework named "NativeScript.apple. node" into our
186- # @nativescript /ios-node-api npm package. The reason we do not use .xcframework
187- # as the file extension is that .node works better for other tooling like
188- # Node.js. It turns out that Apple apps can link XCFrameworks just fine even if
189- # the file extension is not .xcframework!
190- #
191- # The prebuilds standard is described here:
192- # https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
193- OUTPUT_DIR= " packages/ios/build/Release/NativeScript.apple.node "
194- rm -rf $ OUTPUT_DIR
195- deno run -A ./scripts/build_xcframework.mts --output " $OUTPUT_DIR " ${XCFRAMEWORKS[@]}
193+
194+ if [[ " $TARGET_ENGINE " == " none " ]] ; then
195+ checkpoint " Creating the XCFramework ( NativeScript.apple.node) "
196+
197+ # We adhere to the prebuilds standard as described here:
198+ # https://github.com/callstackincubator/react-native- node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
199+ OUTPUT_DIR= " packages /ios/build/Release/NativeScript.apple.node "
200+ rm -rf $OUTPUT_DIR
201+ deno run -A ./scripts/build_xcframework.mts --output " $OUTPUT_DIR " ${XCFRAMEWORKS[@]}
202+ else
203+ checkpoint " Creating NativeScript.xcframework "
204+
205+ OUTPUT_DIR= " $DIST /NativeScript.xcframework "
206+ rm -rf $ OUTPUT_DIR
207+ xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output " $ OUTPUT_DIR"
208+ fi
196209
197210fi
198211
0 commit comments