react-native: Command PhaseScriptExecution failed with a nonzero exit code - Error when Archive on Xcode 14.3
Description
Hi Guys, I’m trying to perform an archive using 0.71.5 but I’m getting an error.
The error occurs in Build phase “[CP] Embed Pods Frameworks”, when he runs the script with:
“${PODS_ROOT}/Target Support Files/Pods-MyApp/Pods-MyApp-frameworks.sh”
React Native Version
0.71.5
Output of npx react-native info
System: OS: macOS 13.3 CPU: (8) arm64 Apple M1 Memory: 79.22 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm Watchman: 2022.11.14.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/leonardo.felipe/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: API Levels: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0 System Images: android-32 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a Android NDK: 22.1.7171670 IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: 11.0.14.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.5 => 0.71.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
- Create a project in 0.71.5
- Try to perform an archive
- Archive will fail in build phase “[CP] Embed Pods Frameworks”
Snack, code example, screenshot, or link to a repository
Investigating the problem I noticed that the problem occurs in the “Symlinked…” of the script Pods-MyApp-frameworks.sh
if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink "${source}")"
fi
Workaround is to update all the generated …-frameworks.sh files to add the -f flag to the call to readlink. In other words, replace source=“$(readlink “${source}”)” with source=“$(readlink -f “${source}”)”
The Workaround above was suggested for the issue below and has now been merged into the cocoapods repository. I believe we will need an RC with this FIX pointing to the new version of cocoapods as soon as it is released.
https://github.com/CocoaPods/CocoaPods/issues/11808 https://github.com/CocoaPods/CocoaPods/pull/11828
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 20
- Comments: 116 (3 by maintainers)
Facing the same issue.
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
UPDATE adding ‘-f’ on the highlighted line in this file resolved my issue. You can try this
Fixed this by updating updating
node_modules/react-native/scripts/find-node.sh
@ L7P.S. Tried switching node from nvm to brew but that didn’t made any difference.
Having the same issue. Apple M2 Pro, Xcode 14.3.
The solution that worked for me was to delete “.xcode.env.local” and start the whole process again
Try to check the
ios/.xcode.env
file.Inside, there should be the line:
export NODE_BINARY=$(command -v node)
Try replacing it with:
export NODE_BINARY=your_node_path
for example, it can be:export NODE_BINARY=/Users/myuser/.nvm/versions/node/v18.15.0/bin/node
I just encountered this upgrading a project from
0.73.3
to0.73.4
with Xcode 15.2. The solution for me was to delete the./ios/.xcode.env.local
file. It was overriding the correct settings in./ios/.xcode.env
.God, you saved me!!!
any solution? XCode 15 + RN 0.72.5 same problem
@dacowles I’ve done as described here and it solved my issue
remove space from project folder name.
Try this:
sudo ln -s "$(which node)" /usr/local/bin
source="$(readlink -f "${source}")"
did not fix for me. I am using M2 pro and xcode 14.3 React native version: 0.65.3try this, it worked for me
my issue was the
node_modules/react-native/scripts/react-native-xcode.sh
script, specifically the IP env variable. I’ve replaced the for loop and if check, with the fallback command:I’m not sure what the cause of this error is, but maybe this helps someone else
I did this “Move the project folder in a path with no spaces (i.e. ~/sub folder name/ReactNativeApp won’t work till you have spaces in the path, so move in a path like ~/folder/ReactNativeApp)” and then deleted and re-created the project
Same issue with React Native 0.72.6 and xcode 15.0.1 and M1
@RenzoPH have you tried updating cocoapods to version 1.12.1? Updating to the mentioned version solved all my issues
I appreciate your answer, but it’s not my case. I don’t have spaces in any folder. I’ve tried everything in this thread and still not working
source="$(readlink -f "${source}")"
is already in my pods configuration, it still failing when I try to run the project on my iPhone wired connected to my M1 pro with xcode 14.3 (also tried 14.3.1 and 14.2) with react-native 0.71 and 0.72This worked on the latest react-native (0.73.5).
Also, if your build works and then the next build fails, a clean might fix it.
I fixed it by configuring the NODE_BINARY variable inside
.xcode.env
(available as of RN 0.69):adding -f but doesn’t work yet in m1 Mac too
works for me too!
Same issue with React Native “0.73.2” and xcode 14.0 and M1
Seconding this - commenting this out fixes builds for physical devices. This issue doesn’t appear when building for the Simulator
This worked for me.
I’m getting this issue in m1 mac. Can anyone give some exact solution for this?
this issue is occurring due to change in node version. Solution for that is when you upgrade your node version just delete “.xcode.env.local” file and build again. I will work like piece of cake. thanks.
This exactly what I need to fix the issue on RN 0.72.6, xCode 15.01 and Mac M1
facing same issue Xcode version 14.3.1 (14E300c). assist me on this
still not working for me , is there any solution ?
@undeath55 thank you this solution worked.
This help me to fix the issue. https://developer.apple.com/forums/thread/725230 Please have a look, may be this will help…!
check for spaces as you are naming the project folders. Use space alternatives.
Yes, same issue here after upgrading to Xcode 14.3. Cocoapods is broken in this release. Anyone been able to resolve?
While trying to upgrade step by step from 0.69.1 to 0.71.5 step by step I have not gotten fastlane to build the latest week. iOS simulator runs fine.
I have applied the target deployment version patch and set my Gemfile for
which resolves to https://github.com/CocoaPods/CocoaPods/commit/3ac99beed81d11a830bdce2fac761a49bae47e83.
Given these changes a clean out and pod-reinstall I’m still seeing symlink issues after running this darling command:
from the ios folder.
The log output from fastlane is saying:
Which to me clearly indicates a still present symlink issue. Are we still convinced this is a cocoapods-issue or how RN uses cocoapods or the script? I’m happy to move this issue to the cocoapods-repo but it seems to me it might be due to some internal use in
DoubleConversion
?Also, cocoapods does not accept issues with RN/Flutter, as per their new issue template. I am not sure where to start to make this a reproducible issue without RN.
Found some more info and what looks like a root cause of this issue when running commands with
yarn
https://github.com/facebook/react-native/pull/43333check if anyything is running on port 8081 and kill it, worked for me
This worked for me
THANKSSS this is working for me!!
Xcode: 14.2 Cocoapod: 1.12.1
+1
#Fixed this by
set -e
stops the execution of a script if a command or pipeline has an error - which is the opposite of the default shell behaviour, which is to ignore errors in scripts. but I dont have any error logs so I dont know what causes this script to fail.Surprisingly this works for me, tqvm!! Anyone know what does this change means?
I’ve tried several things: clean build / reinstall pod / restart and re-pair device but doesn’t work. My case was pretty weird as I had no issue running on simulator (17.4) but hits with this error when trying to run on physical device (ios 17.4.1). No idea why this is happening.
how i fix for me i have a space in foldername like " app name " in main file after removing the space its start working
change index.tsx or index.ts to index.js
Same here
Upgraded the react-native to the latest version (0.73.6) and it works.
Worked for me thanks👍
I opened the logs in XCode and saw that my error falls in “Bundle React Native code and images” and in the recommendations it was written that two libraries should be install “Please install react-dom@18.2.0, @expo/metro-runtime@~3.1.1”. I installed the libraries using the command “npx expo install react-dom @expo/metro-runtime” and that helped me.
#Hi,
I am also getting the same error.
like [Command PhaseScriptExecution failed with a nonzero exit code]
magnet@Magnets-MacBook-Pro Grocery % npx react-native info info Fetching system and libraries information… System: OS: macOS 14.3 CPU: (8) arm64 Apple M2 Memory: 104.13 MB / 8.00 GB Shell: version: “5.9” path: /bin/zsh Binaries: Node: version: 18.16.0 path: /usr/local/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 9.6.6 path: /opt/homebrew/bin/npm Watchman: version: 2023.05.22.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.2 - iOS 17.2 - macOS 14.2 - tvOS 17.2 - visionOS 1.0 - watchOS 10.2 Android SDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: version: 15.2/15C500b path: /usr/bin/xcodebuild Languages: Java: version: 17.0.10 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: “@react-native-community/cli”: Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.73.2 wanted: 0.73.2 react-native-macos: Not Found npmGlobalPackages: “react-native”: Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false
i updated to 0.71.11 and did not get this error initially when running
yarn ios
. it only appeared when i ran the project through xcode. afterwards it also started happening when runningyarn ios
.so i deleted derived data:
rm -rf ~/Library/Developer/Xcode/DerivedData
and clear build folder/cache with:
https://github.com/pmadruga/react-native-clean-project
then it worked again when i ran
yarn ios
. so i will just avoid running the project through xcode.edit:
xcode working fine again later for whatever reason.
Thanks! Worked for me!