From 3d00470ea2c2d5f3240dcb8aac41b89e005dacdd Mon Sep 17 00:00:00 2001 From: Jean Regisser Date: Fri, 5 Jul 2024 16:59:49 +0200 Subject: [PATCH] chore: fix inconsistent node path in Xcode build scripts (#31) (#5620) ### Description Since I got errors related to node's path when building from Xcode directly, I noticed the way we're detecting node's path in Xcode build phases is inconsistent with what React Native 0.69+ does now. RN now recommends using [`node_modules/react-native/scripts/xcode/with-environment.sh`](https://github.com/facebook/react-native/blob/06fc6f2beb9a6733ada7791dd91e2b9ec28d0c0e/packages/react-native/scripts/xcode/with-environment.sh) everywhere. We had manually modified logic in several build phrase scripts, which were not doing the same thing. Leading to possibly using different node binaries between these different scripts. Backported from https://github.com/valora-inc/troopo/pull/31 See also https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/ Since the diff is hard to read, here are screenshots of the updated build phases: Screenshot 2024-07-05 at 16 11 39 Screenshot 2024-07-05 at 16 11 58 ### Test plan - CI passes ### Related issues N/A ### Backwards compatibility Yes ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [x] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added) --- ios/celo.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/celo.xcodeproj/project.pbxproj b/ios/celo.xcodeproj/project.pbxproj index 5a28ef67ae9..68322344b92 100644 --- a/ios/celo.xcodeproj/project.pbxproj +++ b/ios/celo.xcodeproj/project.pbxproj @@ -556,7 +556,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# First set the path to sentry.properties\nexport SENTRY_PROPERTIES=sentry.properties\n\n# Setup nvm and set node\n[ -z \"$NVM_DIR\" ] && export NVM_DIR=\"$HOME/.nvm\"\n\nif [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\n\n# Set up the nodenv node version manager if present\nif [[ -x \"$HOME/.nodenv/bin/nodenv\" ]]; then\neval \"$(\"$HOME/.nodenv/bin/nodenv\" init -)\"\nfi\n\n# Set up asdf version manager if present\nif [[ -s \"$HOME/.asdf/asdf.sh\" ]]; then\n. \"$HOME/.asdf/asdf.sh\"\nfi\n\n[ -z \"$NODE_BINARY\" ] && export NODE_BINARY=\"node\"\n\n# Fixes bundling failing with our monorepo setup\nexport PROJECT_ROOT=\"$PROJECT_DIR/..\"\n\nif [[ \"$APP_BUNDLE_ID\" = \"org.celo.mobile.test\" ]]; then\n ../node_modules/react-native/scripts/react-native-xcode.sh\nelse\n $NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \\\n ../node_modules/react-native/scripts/react-native-xcode.sh\nfi\n"; + shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_XCODE=\"../node_modules/@sentry/react-native/scripts/sentry-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE\"\n\nif [[ \"$APP_BUNDLE_ID\" = \"org.celo.mobile.test\" ]]; then\n /bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\nelse\n /bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\nfi\n"; }; 0FA148AE242137AC009239C6 /* Copy GoogleService-Info.plist */ = { isa = PBXShellScriptBuildPhase; @@ -783,7 +783,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [[ \"$CONFIGURATION\" = *Debug* ]]; then\n echo \"Debug build; skipping upload debug symbols.\"\n exit 0\nfi\n\nif [[ \"$APP_BUNDLE_ID\" = \"org.celo.mobile.test\" ]]; then\n echo \"Test build; skipping upload debug symbols.\"\n exit 0\nfi\n\nexport SENTRY_PROPERTIES=sentry.properties\n\n# Setup nvm and set node\n[ -z \"$NVM_DIR\" ] && export NVM_DIR=\"$HOME/.nvm\"\n\nif [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\n\n# Set up the nodenv node version manager if present\nif [[ -x \"$HOME/.nodenv/bin/nodenv\" ]]; then\neval \"$(\"$HOME/.nodenv/bin/nodenv\" init -)\"\nfi\n\n[ -z \"$NODE_BINARY\" ] && export NODE_BINARY=\"node\"\n\n$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli debug-files upload \"$DWARF_DSYM_FOLDER_PATH\"\n"; + shellScript = "if [[ \"$CONFIGURATION\" = *Debug* ]]; then\n echo \"Debug build; skipping upload debug symbols.\"\n exit 0\nfi\n\nif [[ \"$APP_BUNDLE_ID\" = \"org.celo.mobile.test\" ]]; then\n echo \"Test build; skipping upload debug symbols.\"\n exit 0\nfi\n\n/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh\n"; }; /* End PBXShellScriptBuildPhase section */