Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command PhaseScriptExecution failed with a nonzero exit code #32984

Closed
hellforever opened this issue Jan 28, 2022 · 51 comments
Closed

Command PhaseScriptExecution failed with a nonzero exit code #32984

hellforever opened this issue Jan 28, 2022 · 51 comments
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: Unsupported Version Issues reported to a version of React Native that is no longer supported

Comments

@hellforever
Copy link

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(R) Core(TM) 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

@dehlen
Copy link
Contributor

dehlen commented Jan 28, 2022

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.

@JonnyLinja
Copy link

JonnyLinja commented Jan 31, 2022

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.

#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.

@hellforever
Copy link
Author

@dehlen
Copy link
Contributor

dehlen commented Feb 1, 2022

I do not use nvm but asdf-vm to manage my node versions. What worked for me was to have a look at the node_modules/react-native/scripts/find-node.sh script and to make sure that the script can find my current node version. None of the both paths for asdf were available on my machine which is why I had this error. Once I symlinked my asdf.sh from . /usr/local/opt/asdf/libexec/asdf.sh to $HOME/.asdf/asdf.sh the build started to work for me.

@krlol
Copy link

krlol commented Feb 3, 2022

Cleaning the project and re-running worked for me

@vaughnkoch
Copy link

@dehlen, @krlol, @JonnyLinja agreed that cleaning & rebuilding works at least to solve the cancelButtonTintColor issue - it looks like FBReactNativeSpec.h is generated on the fly. Cleaning the build regenerated that file for me.

@pedrorenan
Copy link

pedrorenan commented Feb 15, 2022

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

Commented line 89
image

@aramyesildeniz
Copy link

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"

@surajSanwal
Copy link

surajSanwal commented Mar 8, 2022

This worked for me

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

This is nothing just an issue with the scheme name for me, in my case my scheme name contains whitespace e.g. "ABC staging", which is not allowed, it got fixed after deleting and creating a new scheme with the name "ABC-staging".

in the case of react-native 0.67^, you may need to apply these changes as well

change line no 7 
set -e. ==> set +e 

in

node_modules/react-native/scripts/find-node.sh

then use patch-package using the following command :

npx patch-package react-native

this will create a patch file inside the patch folder in root, then you can add in the post-install script in package.json:

 "postinstall": "npx patch-package"

This command will run each time a new package is getting added to the project and auto-fix react-native find-node. sh.

@Amr1440
Copy link

Amr1440 commented Mar 13, 2022

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

@surajSanwal
Copy link

surajSanwal commented Mar 13, 2022

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.

@pedrolopes10
Copy link

after some hours, uninstall node from brew and installed directly from node website and worked!

@Jafferson1
Copy link

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

@iqorlobanov
Copy link

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

@ksealey
Copy link

ksealey commented Apr 7, 2022

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

@chenweigh
Copy link

chenweigh commented Apr 28, 2022

Problem

Showing All Errors Only

Build target FBReactNativeSpec of project Pods with configuration Debug

PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/chen/Library/Developer/Xcode/DerivedData/NativeWithReactNativeDemo-cyjlnvbefgrdcbcnrhsxpweyuumx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh (in target 'FBReactNativeSpec' from project 'Pods')
    cd /Users/chen/working/NativeWithReactNativeDemo/Pods
Command PhaseScriptExecution failed with a nonzero exit code

Build failed    2022/4/28, 6:12 PM    40.7 seconds

Podfile

def myRNNewPod
  pod 'YogaKit', '12.3.5.2'
  
  react_native_path = '../react-native-67/react-native'
  
  pod 'FBLazyVector', :path => "#{react_native_path}/Libraries/FBLazyVector"
  pod 'RCTRequired', :path => "#{react_native_path}/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "#{react_native_path}/Libraries/TypeSafety"
  pod 'React-Core', :path => "#{react_native_path}/"
  pod 'React-Core/DevSupport', :path => "#{react_native_path}/"
  pod 'React-RCTActionSheet', :path => "#{react_native_path}/Libraries/ActionSheetIOS"
  
  pod 'React', :path => "#{react_native_path}/"
  pod 'React-CoreModules', :path => "#{react_native_path}/React/CoreModules"
  pod 'React-RCTAnimation', :path => "#{react_native_path}/Libraries/NativeAnimation"
  pod 'React-RCTBlob', :path => "#{react_native_path}/Libraries/Blob"
  pod 'React-RCTImage', :path => "#{react_native_path}/Libraries/Image"
  pod 'React-RCTLinking', :path => "#{react_native_path}/Libraries/LinkingIOS"
  pod 'React-RCTNetwork', :path => "#{react_native_path}/Libraries/Network"
  pod 'React-RCTSettings', :path => "#{react_native_path}/Libraries/Settings"
  pod 'React-RCTVibration', :path => "#{react_native_path}/Libraries/Vibration"

  pod 'React-RCTText', :path => "#{react_native_path}/Libraries/Text"
  pod 'React-Core/RCTWebSocket', :path => "#{react_native_path}/"

  pod 'React-cxxreact', :path => "#{react_native_path}/ReactCommon/cxxreact"
  pod 'React-jsi', :path => "#{react_native_path}/ReactCommon/jsi"
  pod 'React-jsiexecutor', :path => "#{react_native_path}/ReactCommon/jsiexecutor"
  pod 'React-jsinspector', :path => "#{react_native_path}/ReactCommon/jsinspector"
  pod 'React-callinvoker', :path => "#{react_native_path}/ReactCommon/callinvoker"
  pod 'Yoga', :path => "#{react_native_path}/ReactCommon/yoga"
  
  pod 'boost', :podspec => "#{react_native_path}/third-party-podspecs/boost.podspec"
  pod 'DoubleConversion', :podspec => "#{react_native_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{react_native_path}/third-party-podspecs/glog.podspec"
  pod 'RCT-Folly', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec"
  
  pod 'ReactCommon/turbomodule/core', :path => "#{react_native_path}/ReactCommon"
#  pod 'FBReactNativeSpec', :path => "#{react_native_path}/Libraries/FBReactNativeSpec"
  pod 'FBReactNativeSpec', :path => "#{react_native_path}/React/FBReactNativeSpec"

  pod 'React-perflogger', :path => "#{react_native_path}/ReactCommon/reactperflogger"
  pod 'React-runtimeexecutor', :path => "#{react_native_path}/ReactCommon/runtimeexecutor"
  pod 'React-logger', :path => "#{react_native_path}/ReactCommon/logger"
  
end

This is a native project. load 'main.jsbundle' in oc code
How to fix it?
I need help.

@boma25
Copy link

boma25 commented May 7, 2022

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

@taylorkline
Copy link

Cherry-picking 802b3f7 fixed the issue for a dev on my team who was stuck with this issue.

@thaitd0396
Copy link

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

It worked for me, thank bro

@daaanigm
Copy link

daaanigm commented Jun 8, 2022

My problem was that I renamed the index.js root file to index.tsx, if you rename it to index.js it works. 👍

@edinpuzic
Copy link

I also confirm if you change index.ts to index.js it works

@bozaigao

This comment was marked as spam.

@sajjad-karimi
Copy link

sajjad-karimi commented Jun 24, 2022

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

@jjrise
Copy link

jjrise commented Aug 2, 2022

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

brilliant, after trying a million different suggestions this is the one that worked for me.... thanks!

@Bittersweet-Chocolate
Copy link

this work form me with nvm:

这项工作形成了我与 nvm:

first you should uninstall local node :

首先卸载本地节点:

brew uninstall node

酿造卸载节点

and then install the latest version of node with nvm :

然后使用 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

/Users/< user-name >/. nvm/version/node/v < install-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

Nvm unalias 默认值

and then set the new default :

然后设置新的默认值:

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

Nvm alias default < install-version > example = > nvm alias default 14.17.3

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

最后是将节点位置链接到/usr/local/bin/node:

% which node

% 哪个节点

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

/Users/< user-name >/. nvm/version/node/v < install-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

Sudo ln-s/Users/< user-name >/. nvm/version/node/v < install-version >/bin/node/usr/local/bin/node

thank bro,it worked for me

@Garamani
Copy link

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

@Solaimanx
Copy link

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

@hengkx
Copy link

hengkx commented Oct 17, 2022

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

@avinashsahoo
Copy link

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

Great. It worked. But surprisingly it happened only with newer version of React Native. Earlier it used work in that way.

@Talhafayyaz11
Copy link

I am facing the same issue with node version 19 and i deleted the nvm also but none of the solution worked for me.

@ZohaibAhmad786
Copy link

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

you saved my days thanks

@Waryen
Copy link

Waryen commented Dec 2, 2022

I'v got this issue after I've uninstalled my node binary installed by brew because I use volta's node binary.
Apparently Xcode disliked that, I had too reinstall node via brew brew install node@16 BUT didn't updated my path so that I still use my volta's node binary in the terminal.

@ghost
Copy link

ghost commented Mar 24, 2023

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

@dungnguyentri3110
Copy link

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.

Thank you so much. this solution help me out this issue after 1 week stuck

@manuarya
Copy link

manuarya commented Apr 8, 2023

[Resolved] This worked for me
Target > General > Supported Destinations - Remove Mac

@gegana
Copy link

gegana commented Jul 25, 2023

Looks like this is a common problem with users who use NVM. I uninstalled NVM and used N instead for managing node versions. https://www.npmjs.com/package/n

@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Jul 25, 2023
@github-actions

This comment was marked as off-topic.

@zartabkhalil
Copy link

permission issue on the mac machine.sudo chown -R $(whoami) /path/to/project solved for me

@DiorAbjalilov
Copy link

DiorAbjalilov commented Nov 9, 2023

react-native-rncore:error
image

There should be no empty space in the names of folders managing the project. and worked for me

@kigh143
Copy link

kigh143 commented Feb 9, 2024

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 solution worked for me. Initially, I was using Node installed via Brew, but I recently switched to using NVM. That's when I started encountering this issue. However, after running this command, it's now building fine.

@congshengwu
Copy link

I resolved the issue in this way, and I am using nvm to manage nodes.

execute sudo ln -s $(which node) /usr/local/bin/node
command line tools say: ln: /usr/local/bin/node: File exists
execute sudo rm /usr/local/bin/node
execute sudo ln -s $(which node) /usr/local/bin/node again.

Then no error when I run build on Xcode.

@turtle-evolution
Copy link

For me, I find .xcode.env.local and edit version npm for them.
Step 1: which node => get node version ex: v18.14.2
Step 2: versions/node/v16.16.2/bin/node => versions/node/v18.14.2/bin/node
Step 3: run again.
I hope it will help you resolve the issue.

@AdamLee321
Copy link

For me it was the parent folder I had my project in. The parent folder name had a space ("Parent Folder") and once I renamed it to ("ParentFolder") the project built successfully.

@Oladapodaniel
Copy link

Oladapodaniel commented Jun 19, 2024

This fixed it for me
https://stackoverflow.com/a/67289307

@KAMRONBEK
Copy link

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

its giving me error ln: /usr/local/bin/node: File exists

@shabbir-hussain-git
Copy link

For me :

Showing Recent Issues
[Warning] You need to configure your node path in the ".xcode.env" file environment. You can set it up quickly by running: echo export NODE_BINARY=$(command -v node) > .xcode.env in the ios folder. This is needed by React Native to work correctly. We fallback to the DEPRECATED behavior of finding node. This will be REMOVED in a future version. You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment

echo export NODE_BINARY=$(command -v node) > .xcode.env <-- this works rn version 0.75

@davitdarsalia
Copy link

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

That magically helped me. RN version 0.75.

@neiracausevic1
Copy link

If anyone has this issue in RN version 0.73.0:

I did everything written in this thread but it only started working when I downgraded to 0.72.17

@blakef blakef added the Type: Unsupported Version Issues reported to a version of React Native that is no longer supported label Oct 25, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Unsupported Version of React Native
ℹ️ It looks like your issue or the example you provided uses an unsupported version of React Native.

Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.

@migueldaipre
Copy link
Collaborator

migueldaipre commented Oct 31, 2024

Fixed as mentioned here.

Closing for now, feel free to open a new issue if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: Unsupported Version Issues reported to a version of React Native that is no longer supported
Projects
None yet
Development

No branches or pull requests