Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support for --sourcemap-output path containing spaces in Xcode pr…
…ojects (#40937) Summary: This PR contains the changes from #30981 that got closed due to inactivity. Many thanks to nickdowell for this bug report & fix. We encountered this error in our project when we had an Xcode scheme that contains a space (like `AppName alpha`). This change fixes the generation of source maps for Xcode projects where the output path contains spaces. The `EXTRA_ARGS` environment variable, being a plain string, would be split into arguments by whitespace - so a path containing spaces was being treated as several arguments rather than one. This change uses an array to contain the arguments instead, allowing the proper handling of arguments that may contain spaces. bypass-github-export-checks ## Changelog: [iOS] [Fixed] - Fix support for --sourcemap-output path containing spaces Pull Request resolved: #40937 Test Plan: Tested using a sample project with the following "Bundle React Native code and images" Xcode build phase ``` export SOURCEMAP_FILE="$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/main.jsbundle.map" set -e export NODE_BINARY=node ../node_modules/react-native/scripts/react-native-xcode.sh ``` and a `CONFIGURATION_BUILD_DIR` that contains spaces - `~/Library/Xcode/Derived Data`. **You can also try an XCode-scheme that contains a space.** ### Before ``` + EXTRA_ARGS= + case "$PLATFORM_NAME" in + BUNDLE_PLATFORM=ios + EMIT_SOURCEMAP= + [[ ! -z /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map ]] + EMIT_SOURCEMAP=true + PACKAGER_SOURCEMAP_FILE= + [[ true == true ]] + [[ '' == true ]] + PACKAGER_SOURCEMAP_FILE='/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map' + EXTRA_ARGS=' --sourcemap-output /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map' + node /Users/nick/Desktop/RN064/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle' --assets-dest '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app' --sourcemap-output /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map Welcome to Metro! Fast - Scalable - Integrated info Writing bundle output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle info Writing sourcemap output to:, /Users/nick/Library/Developer/Xcode/Derived ``` Note the incorrect sourcemap output path. ### After ``` + EXTRA_ARGS=() + case "$PLATFORM_NAME" in + BUNDLE_PLATFORM=ios + EMIT_SOURCEMAP= + [[ ! -z /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map ]] + EMIT_SOURCEMAP=true + PACKAGER_SOURCEMAP_FILE= + [[ true == true ]] + [[ '' == true ]] + PACKAGER_SOURCEMAP_FILE='/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map' + EXTRA_ARGS+=("--sourcemap-output") + EXTRA_ARGS+=("$PACKAGER_SOURCEMAP_FILE") + node /Users/nick/Desktop/RN064/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle' --assets-dest '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app' --sourcemap-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map' Welcome to Metro! Fast - Scalable - Integrated info Writing bundle output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle info Writing sourcemap output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map ``` sourcemap output path fixed 🎉 Reviewed By: arushikesarwani94 Differential Revision: D52431057 Pulled By: cipolleschi fbshipit-source-id: 528217c84fe3f467a30baa15cfa4dcb2ed713165
- Loading branch information