Skip to content

Commit 5422566

Browse files
committed
follow react-native-node-api conventions only with --no-engine
1 parent 452acd3 commit 5422566

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
@@ -146,53 +146,66 @@ cmake_build macos-cli
146146

147147
fi
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+
149162
XCFRAMEWORKS=()
150163
if $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" )
153166
fi
154167

155168
if $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" )
158171
fi
159172

160173
if $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" )
163176
fi
164177

165178
if $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" )
168181
fi
169182

170183
if $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" )
176189
fi
177190

178191
if [[ -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

197210
fi
198211

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)