From e2c3dbde3d63f0dd6abff7c0ae796b986dd28ea9 Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Tue, 25 May 2021 11:18:51 -0400 Subject: [PATCH] Quote --sourcemap-output argument during ios build 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. --- scripts/react-native-xcode.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 203a9ab186a82d..83c55d43f42dab 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -117,7 +117,7 @@ fi BUNDLE_FILE="$CONFIGURATION_BUILD_DIR/main.jsbundle" -EXTRA_ARGS= +EXTRA_ARGS=() case "$PLATFORM_NAME" in "macosx") @@ -144,12 +144,12 @@ if [[ $EMIT_SOURCEMAP == true ]]; then else PACKAGER_SOURCEMAP_FILE="$SOURCEMAP_FILE" fi - EXTRA_ARGS="$EXTRA_ARGS --sourcemap-output $PACKAGER_SOURCEMAP_FILE" + EXTRA_ARGS+=("--sourcemap-output" "$PACKAGER_SOURCEMAP_FILE") fi # Hermes doesn't require JS minification. if [[ $USE_HERMES == true && $DEV == false ]]; then - EXTRA_ARGS="$EXTRA_ARGS --minify false" + EXTRA_ARGS+=("--minify" "false") fi "$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \ @@ -160,8 +160,8 @@ fi --reset-cache \ --bundle-output "$BUNDLE_FILE" \ --assets-dest "$DEST" \ - $EXTRA_ARGS \ - $EXTRA_PACKAGER_ARGS + "${EXTRA_ARGS[@]}" \ + "${EXTRA_PACKAGER_ARGS[@]}" if [[ $USE_HERMES != true ]]; then cp "$BUNDLE_FILE" "$DEST/"