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)

Most upvoted comments

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

Screenshot 2023-04-13 at 9 56 22 AM

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.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 to 0.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.

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

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.

This is happening to me due to:

env: node: No such file or directory

Would it be possible to get a more helpful error message?

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

try this, it worked for me

# ios/.xcode.env
export NODE_BINARY=$(which node)

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:

# Enables iOS devices to get the IP address of the machine running Metro
if [[ ! "$SKIP_BUNDLING_METRO_IP" && "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
  # for num in 0 1 2 3 4 5 6 7 8; do
  #   IP=$(ipconfig getifaddr en${num})
  #   if [ ! -z "$IP" ]; then
  #     break
  #   fi
  # done
  # if [ -z "$IP" ]; then
  IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' |cut -d\   -f2  | awk 'NR==1{print $1}')
  # fi
  echo "IP: $IP"

  echo "$IP" > "$DEST/ip.txt"
fi

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

What fixed it for me is to move the project to a proper file path. So you want to avoid this desktop/new folder on desktop/yourproject and do this desktop/newfolderondesktop/**yourproject, no spaces or funky characters. clean build folder and Xcode derived data from storage, restart, reopen your project in xcode from the new file path, then run build again. On Fri, Apr 12, 2024 at 8:20 PM Carlos Rivero @.> wrote: This is pretty sick. I don’t know what else I can do. I’ve tried all the possibles solutions in this thread and none of them have worked for me. I really appreciate your help, I need to fix this ASAP. I’m using NVM and default alias is set to latest lts (20.12.1). If I start a new React-Native bare cli project I can run it on xcode without no issues. This is the error that xcode build log returns [image: Uploading Captura de pantalla 2024-04-12 a las 17.37.25.png…] — Reply to this email directly, view it on GitHub <#36762 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A27O777YYJ5BQA2BNGMPN6LY5AXYLAVCNFSM6AAAAAAWQOXYUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGM4TKNRYGM . You are receiving this because you commented.Message ID: @.**>

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

open ios/.xcode.env.local and delete the line starting with export NODE_BINARY.

This 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):

export NODE_BINARY=/Users/xxx/bin/node

adding -f but doesn’t work yet in m1 Mac too Captura de Tela 2023-07-05 às 10 19 23

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

works for me too!

Same issue with React Native “0.73.2” and xcode 14.0 and M1

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:

# Enables iOS devices to get the IP address of the machine running Metro
if [[ ! "$SKIP_BUNDLING_METRO_IP" && "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
  # for num in 0 1 2 3 4 5 6 7 8; do
  #   IP=$(ipconfig getifaddr en${num})
  #   if [ ! -z "$IP" ]; then
  #     break
  #   fi
  # done
  # if [ -z "$IP" ]; then
  IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' |cut -d\   -f2  | awk 'NR==1{print $1}')
  # fi
  echo "IP: $IP"

  echo "$IP" > "$DEST/ip.txt"
fi

I’m not sure what the cause of this error is, but maybe this helps someone else

Seconding this - commenting this out fixes builds for physical devices. This issue doesn’t appear when building for the Simulator

The solution that worked for me was to delete “.xcode.env.local” and start the whole process again

This worked for me.

I’m getting this issue in m1 mac. Can anyone give some exact solution for this?

image

export NODE_BINARY=/Users/myuser/.nvm/versions/node/v18.15.0/bin/node

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.

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

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 ?

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

@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

gem 'cocoapods', git: 'https://github.com/CocoaPods/CocoaPods.git', branch: 'master'

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:

rm -rf ~/Library/Developer/Xcode/DerivedData/ && pod cache clean --all && rm -rf build && cd .. && rm -rf node_modules && npm i && cd ios && pod install; bundle exec fastlane beta config:staging

from the ios folder.

The log output from fastlane is saying:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/IntermediateBuildFilesPath/app_name.build/Release-iphoneos/app_name.build/Script-01409BA429EB16AADA33A048.sh (in target 'app_name' from project 'app_name')
    cd /Users/stefanwallin/iteam/app_name_app/app/ios
    /bin/sh -c /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/IntermediateBuildFilesPath/app_name.build/Release-iphoneos/app_name.build/Script-01409BA429EB16AADA33A048.sh
mkdir -p /Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/BuildProductsPath/Release-iphoneos/app_name.app/Frameworks
Symlinked...
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/DoubleConversion.framework" "/Users/stefanwallin/Library/Developer/Xcode/DerivedData/app_name-dndxchzknwcsfobnpspeueibkplb/Build/Intermediates.noindex/ArchiveIntermediates/app_name/InstallationBuildProductsLocation/Applications/app_name.app/Frameworks"
building file list ... rsync: link_stat "/Users/stefanwallin/iteam/app_name_app/app/ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/DoubleConversion.framework" failed: No such file or directory (2)

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.

WARNING: Please do not file issues for CocoaPods with projects 
that use React Native or Flutter. Please remove React Native or Flutter
in your sample app in order to properly demonstrate an issue with CocoaPods itself.

The integration between CocoaPods and React Native or Flutter 
makes it very difficult for us to diagnose and fix issues.

Issues with React Native or Flutter will be closed.

I just encountered this upgrading a project from 0.73.3 to 0.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.

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/43333

check if anyything is running on port 8081 and kill it, worked for me

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

Screenshot 2023-04-13 at 9 56 22 AM

This worked for me

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

THANKSSS this is working for me!!

Xcode: 14.2 Cocoapod: 1.12.1

+1

#Fixed this by

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

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.

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

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

The solution that worked for me was to delete “.xcode.env.local” and start the whole process again

This worked for me.

Same here

Upgraded the react-native to the latest version (0.73.6) and it works.

Fixed this by updating updating node_modules/react-native/scripts/find-node.sh @ L7

- set -e
+ set +e

P.S. Tried switching node from nvm to brew but that didn’t made any difference.

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. Screenshot 2024-01-30 at 16 59 54 Screenshot 2024-01-30 at 17 01 24 Screenshot 2024-01-30 at 17 01 52

#Hi,

I am also getting the same error.

like [Command PhaseScriptExecution failed with a nonzero exit code] Screenshot at Jan 25 16-13-39

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 running yarn 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.

@RenzoPH have you tried updating cocoapods to version 1.12.1? Updating to the mentioned version solved all my issues

Thanks! Worked for me!