react-native: Command PhaseScriptExecution failed with a nonzero exit code

Description

I followed the instructions from https://reactnative.dev/docs/environment-setup

npx react-native init AwesomeProject npm install then cd to ios directory and run pod install then opened the project with Xcode and trigged build. But the build failed and the error is Command PhaseScriptExecution failed with a nonzero exit code The project could run properly via the command npx react-native run-ios, but could not be built on Xcode, I tried on two different Macbook and got the same error.

Version

0.67.1

Output of npx react-native info

System: OS: macOS 11.6.2 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 126.16 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node Yarn: 1.22.15 - /opt/local/bin/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.18.3/bin/npm Watchman: 2022.01.24.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0 Android SDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.1/13A1030d - /usr/bin/xcodebuild Languages: Java: 11.0.13 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.1 => 0.67.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npx react-native init AwesomeProject npm install then cd to ios directory and run pod install then opened the project with Xcode and trigged build

Snack, code example, screenshot, or link to a repository

image

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 41
  • Comments: 43 (2 by maintainers)

Most upvoted comments

Cleaning the project and re-running worked for me

If you’re getting this with an error about setting the node path, this should fix it.

sudo ln -s $(which node) /usr/local/bin/node

this work form me with nvm:

first you should uninstall local node :

brew uninstall node

and then install the latest version of node with nvm :

nvm install node

and now if you run which node the location should be something like this:

/Users/<user-name>/.nvm/versions/node/v<installed-version>/bin/node

and then you should set the installed version to default version to do this first clear current default with:

nvm unalias default

and then set the new default :

nvm alias default <installed-version> example => nvm alias default 14.17.3

and the last is link the node location to /usr/local/bin/node :

% which node

/Users/<user-name>/.nvm/versions/node/v<installed-version>/bin/node

put the printed address :

sudo ln -s /Users/<user-name>/.nvm/versions/node/v<installed-version>/bin/node /usr/local/bin/node

I had my root folder name “REACT NATIVE”, changing it to “REACT_NATIVE” fixed the error as the folder that contains your react native project cannot contain white spaces

For me worked with: Added line 4 and edited line 16 image

Commented line 89 image

In my case, the problem was related to Not having enough space on my mac.

I use an M2 Mac Air w/ home-brew (but node installed via asdf) and @ksealey 's answer worked for me:

sudo ln -s $(which node) /usr/local/bin/node

Except, I had to make the directory first since it didn’t exist - but it definitely worked:

sudo mkdir /user/local/bin

Edit: I only mention this because I fully expected needing to do sudo mkdir meant the posted solution wouldn’t work for me, and that I’d go back and rm the directory after testing if it worked - But it did work.

This worked for me: I changed MyProject/index.tsx to MyProject/index.js

Same issue for 1 week now i couldn’t resolve it

Which version of node you are using? You can use nvm for switching node versions. For example: nvm use 14.19.0 This version successfully runs a typescript template

I had what appears to be the same issue. Looks to be the same issue as #32951 which shows other people have it too. I am also attempting to run the project via Xcode directly.

https://github.com/facebook/react-native/pull/32712 solved it for me, which is slated for the 0.68 release. For now I temporarily patch-package’d the relevant changes to node_modules/react-native/scripts/find-node.sh to get 0.67.1 running.

Seeing the sample problem. Seems like this run script phase fails due to the latest changes made in RCTActionSheetIOS:

/Users/<redacted>/Developer/app.git-worktrees/feature/branch_name/node_modules/react-native/React/CoreModules/RCTActionSheetManager.mm:98:35: No member named 'cancelButtonTintColor' in 'JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOptions'

When I look at the FBReactNativeSpec header indeed the new property cancelButtonTintColor is missing.

https://stackoverflow.com/a/71392772/4030220

@Amr1440 have you checked my comments, after 2 to 3 days of work I got the solution, the issue may be due to scheme name including special char or need a change in the react-native load script.

After trying out all suggestions and different versions of tools such as XCode, nvm, yarn, node, etc., the only thing that worked for me was to downgrade react native.

In package.json:

"react-native": "0.66.4"

sudo ln -s $(which node) /usr/local/bin/node

This worked for me removing the space in the name of the root directory worked for me

I’ve tried it all and still have problems. react native 0.70.3

unsetting the default alias fixed my issue.

$ nvm unalias default

clean the build folder then rebuild the project.

note : I’m using Xcode 14.0.1

https://stackoverflow.com/a/70944459/15266718