Skip to content

Commit 6623068

Browse files
committed
follow react-native-node-api conventions only with --no-engine
1 parent 0baa365 commit 6623068

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

build_nativescript.sh

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -148,53 +148,66 @@ cmake_build macos-cli
148148

149149
fi
150150

151+
# Due to inconvenient design choices on both sides, we have to choose between
152+
# either long flags or short flags based on whether we're calling
153+
# `xcodebuild -create-xcframework` or `scripts/build_xcframework.mts`.
154+
if [[ "$TARGET_ENGINE" == "none" ]]; then
155+
# Node.js parseArgs() supports short flags, but only if they're single-letter.
156+
FRAMEWORK_FLAG="--framework"
157+
DSYM_FLAG="--debug-symbols"
158+
else
159+
# xcodebuild doesn't implement any single-letter short flags like -f and -d.
160+
FRAMEWORK_FLAG="-framework"
161+
DSYM_FLAG="-debug-symbols"
162+
fi
163+
151164
XCFRAMEWORKS=()
152165
if $BUILD_CATALYST; then
153-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/catalyst/$CONFIG_BUILD-maccatalyst/NativeScript.framework"
154-
--debug-symbols "$DIST/intermediates/catalyst/$CONFIG_BUILD-maccatalyst/NativeScript.framework.dSYM" )
166+
FRAMEWORK="$DIST/intermediates/catalyst/$CONFIG_BUILD-maccatalyst/NativeScript.framework"
167+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
155168
fi
156169

157170
if $BUILD_SIMULATOR; then
158-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/ios-sim/$CONFIG_BUILD-iphonesimulator/NativeScript.framework"
159-
--debug-symbols "$DIST/intermediates/ios-sim/$CONFIG_BUILD-iphonesimulator/NativeScript.framework.dSYM" )
171+
FRAMEWORK="$DIST/intermediates/ios-sim/$CONFIG_BUILD-iphonesimulator/NativeScript.framework"
172+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
160173
fi
161174

162175
if $BUILD_IPHONE; then
163-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/ios/$CONFIG_BUILD-iphoneos/NativeScript.framework"
164-
--debug-symbols "$DIST/intermediates/ios/$CONFIG_BUILD-iphoneos/NativeScript.framework.dSYM" )
176+
FRAMEWORK="$DIST/intermediates/ios/$CONFIG_BUILD-iphoneos/NativeScript.framework"
177+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
165178
fi
166179

167180
if $BUILD_MACOS; then
168-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/macos/$CONFIG_BUILD/NativeScript.framework"
169-
--debug-symbols "$DIST/intermediates/macos/$CONFIG_BUILD/NativeScript.framework.dSYM" )
181+
FRAMEWORK="$DIST/intermediates/macos/$CONFIG_BUILD/NativeScript.framework"
182+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
170183
fi
171184

172185
if $BUILD_VISION; then
173-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/visionos/$CONFIG_BUILD-xros/NativeScript.framework"
174-
--debug-symbols "$DIST/intermediates/visionos/$CONFIG_BUILD-xros/NativeScript.framework.dSYM" )
186+
FRAMEWORK="$DIST/intermediates/visionos/$CONFIG_BUILD-xros/NativeScript.framework"
187+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
175188

176-
XCFRAMEWORKS+=( --framework "$DIST/intermediates/visionos-sim/$CONFIG_BUILD-xros/NativeScript.framework"
177-
--debug-symbols "$DIST/intermediates/visionos-sim/$CONFIG_BUILD-xros/NativeScript.framework.dSYM" )
189+
FRAMEWORK="$DIST/intermediates/visionos-sim/$CONFIG_BUILD-xros/NativeScript.framework"
190+
XCFRAMEWORKS+=( "$FRAMEWORK_FLAG" "$FRAMEWORK" "$DSYM_FLAG" "$FRAMEWORK.dSYM" )
178191
fi
179192

180193
if [[ -n "${XCFRAMEWORKS[@]}" ]]; then
181194

182-
checkpoint "Creating the XCFramework (NativeScript.apple.node)"
183-
184-
# This script used to output to "$DIST/NativeScript.xcframework".
185-
#
186-
# We now follow the react-native-node-api prebuilds standard, emitting an
187-
# XCFramework named "NativeScript.apple.node" into our
188-
# @nativescript/ios-node-api npm package. The reason we do not use .xcframework
189-
# as the file extension is that .node works better for other tooling like
190-
# Node.js. It turns out that Apple apps can link XCFrameworks just fine even if
191-
# the file extension is not .xcframework!
192-
#
193-
# The prebuilds standard is described here:
194-
# https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
195-
OUTPUT_DIR="packages/ios/build/Release/NativeScript.apple.node"
196-
rm -rf $OUTPUT_DIR
197-
deno run -A ./scripts/build_xcframework.mts --output "$OUTPUT_DIR" ${XCFRAMEWORKS[@]}
195+
196+
if [[ "$TARGET_ENGINE" == "none" ]]; then
197+
checkpoint "Creating the XCFramework (NativeScript.apple.node)"
198+
199+
# We adhere to the prebuilds standard as described here:
200+
# https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
201+
OUTPUT_DIR="packages/ios/build/Release/NativeScript.apple.node"
202+
rm -rf $OUTPUT_DIR
203+
deno run -A ./scripts/build_xcframework.mts --output "$OUTPUT_DIR" ${XCFRAMEWORKS[@]}
204+
else
205+
checkpoint "Creating NativeScript.xcframework"
206+
207+
OUTPUT_DIR="$DIST/NativeScript.xcframework"
208+
rm -rf $OUTPUT_DIR
209+
xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output "$OUTPUT_DIR"
210+
fi
198211

199212
fi
200213

build_npm_ios.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ cp ./package.json "$OUTPUT_DIR"
1111

1212
cp -r "./project-template-ios/" "$OUTPUT_DIR/framework"
1313

14-
NATIVESCRIPT_IOS_XCFRAMEWORK="packages/ios/build/Release/NativeScript.apple.node"
15-
if [ ! -d "$NATIVESCRIPT_IOS_XCFRAMEWORK" ]; then
16-
echo "Error: Expected to find the NativeScript iOS XCFramework at path \"$NATIVESCRIPT_IOS_XCFRAMEWORK\". Make sure to run ./build_nativescript.sh before running this script." >&2
17-
exit 1
18-
fi
19-
20-
cp -r $NATIVESCRIPT_IOS_XCFRAMEWORK "$OUTPUT_DIR/framework/internal/NativeScript.xcframework"
21-
rm "$OUTPUT_DIR/framework/internal/NativeScript.xcframework/react-native-node-api-module"
22-
14+
cp -r "dist/NativeScript.xcframework" "$OUTPUT_DIR/framework/internal"
2315
cp -r "dist/TKLiveSync.xcframework" "$OUTPUT_DIR/framework/internal"
2416

2517
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"

prepare_dSYMs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OUTFOLDER="./dist/dSYMs"
55

66
mkdir -p "$OUTFOLDER"
77

8-
for framework_path in ./packages/ios/build/Release/NativeScript.apple.node/ios*; do
8+
for framework_path in ./dist/NativeScript.xcframework/ios*; do
99
DSYMPATH="$framework_path/dSYMs/NativeScript.framework.dSYM"
1010
if [ -d "$DSYMPATH" ]; then
1111
OUTPATH="$OUTFOLDER/$(basename $framework_path)NativeScript.framework.dSYM"

0 commit comments

Comments
 (0)