Skip to content

Commit f3fe7a0

Browse files
andersonvomfacebook-github-bot
authored andcommitted
Quote --sourcemap-output argument during ios build (#31587)
Summary: Scheme names may contain whitespace characters is used as path of the path for various files during build time. This means any path that includes the scheme name in it needs to be surrounded by quotes. You can see the generated command below for a project with a scheme called `Some Scheme`: node ./node_modules/react-native/cli.js bundle \ --entry-file index.js \ --platform ios \ --dev false \ --reset-cache \ --bundle-output './ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app/main.jsbundle' \ --assets-dest './ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app' \ --sourcemap-output ./ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app/main.jsbundle.map `--bundle-output` and `--assets-dest` are properly quoted, but `--sourcemap-output` is not. This changes `$EXTRA_ARGS` to an array of strings so that we can propertly quote `$PACKAGER_SOURCEMAP_FILE` when passing it to the `--sourcemap-output` argument. When running the bundle command, this array is unwrapped and all its elements passed as individual arguments. It also applies the same unwrapping to `$EXTRA_PACKAGER_ARGS` so that users can also pass an array of options when arguments containing spaces are needed. It's important to note that these changes ARE backwards compatible: if `$EXTRA_PACKAGER_ARGS` is defined as a simple string, instead of an array of strings, the command won't break, as it will still expand correctly. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - Source map path for schemes containing whitespaces Pull Request resolved: #31587 Test Plan: With the new change, the generated command becomes: node ./node_modules/react-native/cli.js bundle \ --entry-file index.js \ --platform ios \ --dev false \ --reset-cache \ --bundle-output './ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app/main.jsbundle' \ --assets-dest './ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app' \ --sourcemap-output './ios/derivedDataBuild/Build/Intermediates.noindex/ArchiveIntermediates/Some Scheme/BuildProductsPath/Release-iphoneos/Some Scheme.app/main.jsbundle.map' Reviewed By: yungsters Differential Revision: D30911631 Pulled By: charlesbdudley fbshipit-source-id: 0c2d98746b365285fe693bcc867a24d3fc649f50
1 parent 3e7c310 commit f3fe7a0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/react-native-xcode.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fi
117117

118118
BUNDLE_FILE="$CONFIGURATION_BUILD_DIR/main.jsbundle"
119119

120-
EXTRA_ARGS=
120+
EXTRA_ARGS=()
121121

122122
case "$PLATFORM_NAME" in
123123
"macosx")
@@ -144,12 +144,12 @@ if [[ $EMIT_SOURCEMAP == true ]]; then
144144
else
145145
PACKAGER_SOURCEMAP_FILE="$SOURCEMAP_FILE"
146146
fi
147-
EXTRA_ARGS="$EXTRA_ARGS --sourcemap-output $PACKAGER_SOURCEMAP_FILE"
147+
EXTRA_ARGS+=("--sourcemap-output" "$PACKAGER_SOURCEMAP_FILE")
148148
fi
149149

150150
# Hermes doesn't require JS minification.
151151
if [[ $USE_HERMES == true && $DEV == false ]]; then
152-
EXTRA_ARGS="$EXTRA_ARGS --minify false"
152+
EXTRA_ARGS+=("--minify" "false")
153153
fi
154154

155155
"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
@@ -160,8 +160,8 @@ fi
160160
--reset-cache \
161161
--bundle-output "$BUNDLE_FILE" \
162162
--assets-dest "$DEST" \
163-
$EXTRA_ARGS \
164-
$EXTRA_PACKAGER_ARGS
163+
"${EXTRA_ARGS[@]}" \
164+
"${EXTRA_PACKAGER_ARGS[@]}"
165165

166166
if [[ $USE_HERMES != true ]]; then
167167
cp "$BUNDLE_FILE" "$DEST/"

0 commit comments

Comments
 (0)