react-native
react-native copied to clipboard
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(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
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.
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.
@dehlen @JonnyLinja This solution works for me: https://stackoverflow.com/questions/66742033/phasescriptexecution-cp-user-error-in-react-native/70104375#70104375
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.
Cleaning the project and re-running worked for me
@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.
For me worked with:
Added line 4 and edited line 16
Commented line 89
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"
This worked for me
https://stackoverflow.com/a/71392772/4030220
Same issue for 1 week now i couldn't resolve it
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 some hours, uninstall node from brew and installed directly from node website and worked!
This worked for me: I changed MyProject/index.tsx to MyProject/index.js
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
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
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.
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
Cherry-picking 802b3f778b4d2ecd22882b371a84293421558b8a fixed the issue for a dev on my team who was stuck with this issue.
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
My problem was that I renamed the index.js root file to index.tsx, if you rename it to index.js it works. 👍
I also confirm if you change index.ts to index.js it works
My computer has an M1 chip,I tried everything. The most important changes are as follows: nvm unalias default nvm alias default 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
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!
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
In my case, the problem was related to Not having enough space on my mac.
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
I've tried it all and still have problems. react native 0.70.3
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.
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.