react-native: Command PhaseScriptExecution failed with a nonzero exit code
Description
Trying to load a public react-native project: https://github.com/dramsay9/reactnative-attentionapp and got the below error in Xcode:
/bin/sh -c /Users/zhongs/Library/Developer/Xcode/DerivedData/ReactNativeAttentionTestApp-bxdxpymlnyawuofimfjmwtyperdx/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-5F3DB3CFA631AC0192B75E29E50D22E5.sh
Command PhaseScriptExecution failed with a nonzero exit code
Configuration did to run this project:
- Added GoogleService-Info for Firebase
- Delete Podfile.lock, xcworkspace and pod install
- Update developer profiles
- Removed Flipper (as it’s not used and causing errors)
Version
0.67.2
Output of npx react-native info
info Fetching system and libraries information… System: OS: macOS 12.5 CPU: (8) x64 Intel® Core™ i7-8569U CPU @ 2.80GHz Memory: 185.62 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node Yarn: Not Found npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm Watchman: 2022.08.15.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 1.8.0_332-internal - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
Both “run” using Xcode and npx react-native run-ios --device “” gives the same error.
Snack, code example, screenshot, or link to a repository
Results using npx react-native run-ios --device "
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/zhongs/Library/Developer/Xcode/DerivedData/ReactNativeAttentionTestApp-bxdxpymlnyawuofimfjmwtyperdx/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-5F3DB3CFA631AC0192B75E29E50D22E5.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)
react-native doctor:
✓ Node.js
✖ yarn
- Version found: N/A
- Version supported: >= 1.10.x
✖ Watchman - Used for watching changes in the filesystem when in development mode
- Version found: 2022.08.15.00
- Version supported: 4.x
Android
✓ JDK
✓ Android Studio - Required for building and installing your app on Android
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 30.0.2
✖ ANDROID_HOME
iOS
✓ Xcode - Required for building and installing your app on iOS
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI
env:
NVM_INC=/Users/zhongs/.nvm/versions/node/v16.17.0/include/node
NVM_RC_VERSION=
TERM_PROGRAM=Apple_Terminal
NVM_CD_FLAGS=
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/84/85yg3v756w90md_90mkspt3d0j0qsw/T/
TERM_PROGRAM_VERSION=445
OLDPWD=/Users/zhongs/Desktop/React_native/reactnative-attentionapp-main/ios
TERM_SESSION_ID=D150D757-B20D-4816-8388-2F719173DFCA
NVM_DIR=/Users/zhongs/.nvm
USER=zhongs
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.6jxunqy4sX/Listeners
PATH=/Users/zhongs/.nvm/versions/node/v16.17.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
__CFBundleIdentifier=com.apple.Terminal
PWD=/Users/zhongs/Desktop/MediaLab/visual_comfort/React_native/reactnative-attentionapp-main
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/zhongs
LOGNAME=zhongs
LC_CTYPE=UTF-8
NVM_BIN=/Users/zhongs/.nvm/versions/node/v16.17.0/bin
_=/usr/bin/env
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 19
Fixed it by removing
ios/.xcode.env
&ios/.xcode.env.local
files. As I’m using two devices to build and distribute my app, it generatesios/.xcode.env.local
file which creates this issue.If you were a MacOS user, you would have configured your development environment using zsh by default. However, because bash is used in react-native and expo, there is no node setting in bash, which causes an error. In my case, there was an error building the app in xcode. There are no errors in apps created with react-native, but there are errors in apps created with ignite-cli.
The with-node.sh file references .xcode.env, but could not find a node. So I set the path of the node statically.
After statically setting the node path, the build was successful in xcode.
I tried to follow the guideline for creating a new project: https://reactnative.dev/docs/environment-setup and got the error in this post again. So I guess there were some fundamental setup issues. I found this post: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native and discovered the nvm installed by homebrew that I missed out in the removing process.
So I did the following and finally move on from this error and the app runs 😃. Many thanks!
I managed to fix a similar issue by cleaning and reinstalling the pods after deleting node modules, deleting xcode derived data and reinstall dependencies. I tried to only reinstall pods but it was not enough, removing node-module folder + xcode derived data folder before reinstalling my deps and pods did the trick.
I also encounter this issue. Below is my config settings of react-native info :
Excellent solution ever 👌, I have tried lots of solution like setup “symlink” etc… but after two days continues r&d I found your solution and within 5-min I removed “nvm” from my mac system and install node alone and it’s work like a charm. Thank you 🙂
RN Version: 67.5 Node Version: 16.16.0 Mac System: Intel i3 xCode Version: 14.3.1
You shouldn’t use
nvm
becausenode_modules/react-native/scripts/find-node.sh
file in old React Native can’t find path tonode
. Removingnvm
can resolve your problem.Source: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native