-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix support for --sourcemap-output path containing spaces in Xcode projects #40937
Conversation
This change fixes the generation of source maps for Xcode projects where the output path contains spaces.
Hi @JorenVos! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
CLA should be fine. |
Base commit: edb7332 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
When will this PR be merged? |
Bump |
1 similar comment
Bump |
@cipolleschi any concerns with this? |
The changes looks good to me, the problem is that those script are very brittle. These changes seem to sanitize the params, so I'm positive in try to import and landing these. |
Also see #41845 |
App is crashing for me when I add these changes.
Reproducible example here. I'm setting SOURCEMAP_FILE to "$DERIVED_FILE_DIR/main.jsbundle.map" and this is probably an edge case of your code. In my case the fix was pretty simple as you can see on PR #41845. |
Hi @JorenVos and @maykonmichel, thanks for your PRs. @maykonmichel did you apply your PR (#41845) on top of this one? I'm trying to understand whether we need both or yours would be enough for everyone. |
…Xcode projects [PR #40937](facebook/react-native#40937)
/rebase - this comment will rebase this PR on top of main |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in e25a9b4. |
…ojects (facebook#40937) Summary: This PR contains the changes from facebook#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: facebook#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
Summary: Properly handle targets with spaces in their names Use quotes around the argument to basename path. Ensures this succeeds when the Xcode target name has spaces. example: ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename $SOURCEMAP_FILE)" echo $BN_SOURCEMAP_FILE ``` output: ``` Jane Jane main.jsbundle.map ``` ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename "$SOURCEMAP_FILE")" echo $BN_SOURCEMAP_FILE ``` output: ``` main.jsbundle.map ``` ## Changelog: [iOS] [Fixed] - Fix support for SOURCEMAP_FILE path containing spaces ## Related #40937 Pull Request resolved: #42220 Reviewed By: christophpurrer Differential Revision: D52650491 Pulled By: arushikesarwani94 fbshipit-source-id: e42b8a0d018b37fb558abd53d765fbdd676c51a2
) Summary: Properly handle targets with spaces in their names Use quotes around the argument to basename path. Ensures this succeeds when the Xcode target name has spaces. example: ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename $SOURCEMAP_FILE)" echo $BN_SOURCEMAP_FILE ``` output: ``` Jane Jane main.jsbundle.map ``` ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename "$SOURCEMAP_FILE")" echo $BN_SOURCEMAP_FILE ``` output: ``` main.jsbundle.map ``` ## Changelog: [iOS] [Fixed] - Fix support for SOURCEMAP_FILE path containing spaces ## Related facebook#40937 Pull Request resolved: facebook#42220 Reviewed By: christophpurrer Differential Revision: D52650491 Pulled By: arushikesarwani94 fbshipit-source-id: e42b8a0d018b37fb558abd53d765fbdd676c51a2
Summary: Properly handle targets with spaces in their names Use quotes around the argument to basename path. Ensures this succeeds when the Xcode target name has spaces. example: ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename $SOURCEMAP_FILE)" echo $BN_SOURCEMAP_FILE ``` output: ``` Jane Jane main.jsbundle.map ``` ```sh #!/bin/sh SOURCEMAP_FILE="ArchiveIntermediates/Jane Doe/IntermediateBuildFilesPath/Jane Doe.build/Release-iphoneos/JaneDoe.build/DerivedSources/main.jsbundle.map" BN_SOURCEMAP_FILE="$(basename "$SOURCEMAP_FILE")" echo $BN_SOURCEMAP_FILE ``` output: ``` main.jsbundle.map ``` ## Changelog: [iOS] [Fixed] - Fix support for SOURCEMAP_FILE path containing spaces ## Related #40937 Pull Request resolved: #42220 Reviewed By: christophpurrer Differential Revision: D52650491 Pulled By: arushikesarwani94 fbshipit-source-id: e42b8a0d018b37fb558abd53d765fbdd676c51a2
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
).Summary:
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.
Changelog:
[iOS] [Fixed] - Fix support for --sourcemap-output path containing spaces
Test Plan:
Tested using a sample project with the following "Bundle React Native code and images" Xcode build phase
and a
CONFIGURATION_BUILD_DIR
that contains spaces -~/Library/Xcode/Derived Data
. You can also try an XCode-scheme that contains a space.Before
Note the incorrect sourcemap output path.
After
sourcemap output path fixed 🎉