sentry-react-native: 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!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 31 (4 by maintainers)
I also encountered the same issue and fixed and got help from this post. This is actually what happen. “react-native-xcode.sh” script is in two differant paths in two different react-native versions. and this script is referred in x-code build process. please take a look at the images. according to the react-native version, You has to find where is this script and update the path in Xcode then it will start to work. In X-Code project Project > target > Build Phases > Bundle React Native code and images
or
Path 1 YourProject > node_modules > react-native > scripts > react-native-xcode.sh
or Path 2 YourProject > node_modules > react-native > packager > react-native-xcode.sh
I hope this will be more clear to all.
Doing
brew install node
solves the issue.Spent few hours trying to solve this. It was weird that the file mentioned actually did exist (in your case
/Users/khagesh/Library/Developer/Xcode/DerivedData/CP-awyselqwjoqrjfeypmvugdxlaeoa/Build/Intermediates/CP.build/Debug-iphonesimulator/CP.build/Script-00DD1BFF1BD5951E006B06BC.sh
), but the paths in it were wrong. In my case, I had react native 0.46.1.See this pull request https://github.com/getsentry/react-native-sentry/pull/139/files Basically what I did is replace in all the project (it was in around 3 files)
node_modules/react-native/packager/react-native-xcode.sh
withnode_modules/react-native/scripts/react-native-xcode.sh
That is true for react native 0.46+. However, I don’t think it is solution for the problem in general. Also, I am using react native 0.44 and unfortunately we are not planning an upgrade as of now. But the good news for me is that I solved my issue and also found out the seeming root cause after learning about custom build phases in xcode project.
Here is what I did to resolve my issue. Since
sentry-cli
is not a bash script, it is a node script. I addednode
in front ofsentry-cli
command and that resolved my issue withBundle React Native Code And Images
phase.What react-native-sentry updated
I changed it to add
node
After resolving this issue I faced same issue with
Upload Debug Symbols to Sentry
phase. So I addednode
in front of this script as well. However, this time I got the error thatnode
command not found. It was strange since same script was working onBundle
phase. So, to resolve this issue I created a bash script of my own. Basically I sourcednvm
again and set node in same script and then executed upload command. My script looks something like thisAnd then I replaced build phase with something like this and everything started working.
Root cause for all of these issues that I strongly believe is how
node
is setup. Ifnode
is being setup usingbrew
then default script provided byreact-native-sentry
will work. But ifnode
is being setup withnvm
, then we will face these issues. To confirm my theory I took help from my colleague who was usingnode
usingbrew
and without any change in build phase script his project was compiling just fine.As to why I had to create a bash script for
upload
phase and not just addingnode
worked. I don’t have the slightest of idea. I tried few possible reason but couldn’t come up with strong reason. Anyway I have fixed it for me as of now. I don’t know if we need to update docs orreact-native-sentry
link step to update script.I’m using nvm and I have the same issue during xCode building.
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
: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
It seems this is the way to fix it if you are using
nvm
Similar to what @khagesh posted https://github.com/facebook/react-native/issues/3935 I will close this for now since this is unrelated to Sentry, more about node/mac/XcodeFacing the same issue in React Native 0.69.3
@khagesh Good idea, will do that. 👍 Thx
I’ve also found that using node through NVM was a problem and installed using brew. NVM node works fine under linux for android builds however
The solution for our team was to specify the correct cli executable within our
sentry.properties
since we are using a mono-repo:Guys could you someone explain to me briefly what is that modification of “React Native Bundle” phase even necessary? I am trying to separate sending sentry debug symbols from actual build because I don’t need to upload these files to sentry during development, only on CI tool during production build. So I removed sentry build phase from my project but then I still see after build that something is uploading to sentry which was very weird so I took a look into project file and realized that the bundle phase is also changed by sentry. Any way how to completely separate sending symbolic files from actual build?
Original script in bundle phase: export NODE_BINARY=node\n…/node_modules/react-native/scripts/react-native-xcode.sh
After installing sentry: 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/scripts/react-native-xcode.sh
I think we can update the docs to let people know what to do in case of
nvm
.