Build fails on Xcode. Run custom shell script 'Bundle React Native code and images'
After I added sentry I am getting this error while building project.
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/khagesh/Library/Developer/Xcode/DerivedData/CP-awyselqwjoqrjfeypmvugdxlaeoa/Build/Intermediates/CP.build/Debug-iphonesimulator/CP.build/Script-00DD1BFF1BD5951E006B06BC.sh
export ...
.........
/bin/sh -c /Users/khagesh/Library/Developer/Xcode/DerivedData/CP-awyselqwjoqrjfeypmvugdxlaeoa/Build/Intermediates/CP.build/Debug-iphonesimulator/CP.build/Script-00DD1BFF1BD5951E006B06BC.sh
env: node: No such file or directory
react-native: 0.44
react-native-sentry: 0.14.3
Xcode version: 8.3.3
I am using bitcode, but I don't think it should fail build.
I believe I followed all steps correctly of setting up sentry and checked sentry.properties file which has all things that are needed. Any help will be much appreciated. Thanks!
For me I had to remove react-native-sentry by using react-native unlink react-native-sentry and following the uninstallation process. Then I also removed the dependency from my package.json and ran rm -rf node_modules && yarn.
Next I had to remove references to Sentry in my index.ios.js and app.js files, as well as all the references in my AppDelegate.m.
In the build phases of my project target I removed this line from "Bundle React Native code and images": ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode and I also deleted the "Upload Debug Symbols to Sentry" section.
After building the project it was able to run again, so I re-added the Sentry package and went through the installation process with:
yarn add react-native-sentry
react-native link react-native-sentry
And it is now working, hope this helps!
I'm upgrading from a pretty old version of Sentry and got it working by changing the path from /sentry-cli-binary/ to /@sentry/cli/ in project.pbxproj:
- shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/sentry-cli-binary/bin/sentry-cli react-native xcode ../node_modules/react-native/packager/react-native-xcode.sh";
+ shellScript = "export NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh";
I ran into this after having updated node and realized (after way too long) that the run script was pointing to a node binary that no longer existed on my system 😂
I'm upgrading from a pretty old version of Sentry and got it working by changing the path from
/sentry-cli-binary/to/@sentry/cli/inproject.pbxproj:- shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/sentry-cli-binary/bin/sentry-cli react-native xcode ../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh";
If you take this solution, just make sure you still have the config file in there. Otherwise, it'll yell at you to add the --org and --project and all that when you try to build. Essentially, the only offending part in the broken script is this: \nexport
This is still a problem. Another fix is here for NVM users: https://stackoverflow.com/a/50419734/8676545
Create symlink:
ln -s $(which node) /usr/local/bin/node
For me, I renamed my Sentry project and ran into this error... after wasting my life on hunting node issues all it took was setting the defaults.project in sentry.properties to the new project name for it to work!
Guys, there is still no clear solution as far I as I can see.
Create symlink:
ln -s $(which node) /usr/local/bin/node
I see that the above is now the "sanctioned" solution as per the docs, but it is not a good solution because I don't want to override node system-wide!
Any other ideas?
FWIW what I ended up doing is modifying the last 2 lines of the build steps "Bundle react native node and images" AND "Upload debug symbols to Sentry" to:
export NODE_BINARY=/hard/coded/path/to/correct/node
/hard/coded/path/to/correct/node <PREVIOUS CONTENTS OF LAST LINE>
This forces the sentry CLI script to use the same version of node as my project.
IMO your docs should be updated with a better solution
Facing the same issue in React Native 0.69.3
Here is solution from Sentry docs
The solution for our team was to specify the correct cli executable within our sentry.properties since we are using a mono-repo:
cli.executable=../../node_modules/@sentry/cli/bin/sentry-cli
This is still a problem. Another fix is here for NVM users: https://stackoverflow.com/a/50419734/8676545
Create symlink:
ln -s $(which node) /usr/local/bin/node
@sinn1 Big thanks. I was trying on xcode15.3, Finally its working