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 - Error when Archive on Xcode 14.3 #36762

Open
leofolive opened this issue Apr 2, 2023 · 115 comments

Comments

@leofolive
Copy link

leofolive commented Apr 2, 2023

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.

CocoaPods/CocoaPods#11808
CocoaPods/CocoaPods#11828

@netvalue-emursali
Copy link

Having the same issue. Apple M2 Pro, Xcode 14.3.

@JacobFJ
Copy link

JacobFJ commented Apr 3, 2023

+1

1 similar comment
@Daha62
Copy link

Daha62 commented Apr 3, 2023

+1

@milind-betaflux
Copy link

milind-betaflux commented Apr 3, 2023

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

@kelset
Copy link
Collaborator

kelset commented Apr 3, 2023

duplicate of #36739

@kelset kelset closed this as completed Apr 3, 2023
@leofolive
Copy link
Author

leofolive commented Apr 3, 2023

@kelset
I believe that although this question deals with an error in the same build phase, it seems to me that it pertains to different matters.

The patch reported in the problem you cited, does not solve my problem.

I had a very strange issue where the pods frameworks script would fail to copy the framework files when archiving a build (building worked fine).

@johnsoncwb
Copy link

@kelset
can you check again this error?
it looks different for me from #36739

@kelset
Copy link
Collaborator

kelset commented Apr 3, 2023

re opening - but it looks like it's not a react-native problem, but cocoapods, so not really anything we can do about it CocoaPods/CocoaPods#11828 --- I'll pass it along

@kelset kelset reopened this Apr 3, 2023
@kelset kelset added Platform: iOS iOS applications. Tool: Xcode labels Apr 3, 2023
@StefanWallin
Copy link

StefanWallin commented Apr 3, 2023

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 CocoaPods/CocoaPods@3ac99be.

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.

@salamohamad

This comment was marked as duplicate.

@OrbitalTech

This comment was marked as duplicate.

@cegonzal1991

This comment was marked as duplicate.

@dacowles
Copy link

dacowles commented Apr 4, 2023

Yes, same issue here after upgrading to Xcode 14.3. Cocoapods is broken in this release. Anyone been able to resolve?

@alroniks
Copy link

alroniks commented Apr 4, 2023

@dacowles I've done as described here and it solved my issue

@maks1mp
Copy link

maks1mp commented Apr 6, 2023

Same issue. React Native 0.65.
The following build commands failed:
CompileC /{path}/mobile/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Yoga' from project 'Pods')
(1 failure)

@ianmgithua
Copy link

check for spaces as you are naming the project folders. Use space alternatives.

@rovin01
Copy link

rovin01 commented Apr 13, 2023

This help me to fix the issue. https://developer.apple.com/forums/thread/725230 Please have a look, may be this will help..!

@danidaryaweesh
Copy link

For everyone still having this issue, I recommend to follow the instructions in this link and add a post install script for now.

@RenzoPH
Copy link

RenzoPH commented Apr 29, 2023

Hi, anyone are experience these issue?

Processing Info.plist

▸ Running script ‘[CP] Embed Pods Frameworks’

▸ Generating ‘App.app.dSYM’

** ARCHIVE FAILED **

The following build commands failed:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/runner/Library/Developer/Xcode/DerivedData/App-azlyibamtvkrbhfwntgmcwffjqtw/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target ‘App’ from project ‘App’)

(1 failure)

@danidaryaweesh
Copy link

danidaryaweesh commented Apr 30, 2023

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

@pranshuchittora
Copy link

pranshuchittora commented May 5, 2023

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.

@Yohanson555
Copy link

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

Thanks! Worked for me!

@margox
Copy link

margox commented May 5, 2023

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!!!!!!!!

@rdnsan
Copy link

rdnsan commented Jan 10, 2024

try this, it worked for me

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

@lucaswitch
Copy link

lucaswitch commented Jan 10, 2024

For anyone still having this issue, it could be a miss on import statement on js code.
Just run: yarn run ios(or similar) then the terminal must show the complete error stacktrace.

@sonnv106
Copy link

Same issue with React Native "0.73.2" and xcode 14.0 and M1

@kumarsaurav26198
Copy link

#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

@WBohdan
Copy link

WBohdan commented Jan 30, 2024

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

@RaguRam1991
Copy link

set +e

this worked for me, thanks.

@RaguRam1991
Copy link

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.

it seems we need to change it everytime when installing/uninstalling a package.

@leofolive
Copy link
Author

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.

it seems we need to change it everytime when installing/uninstalling a package.

A patch can be generated using patch-package.

@markrickert
Copy link
Contributor

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.

@umartariq247
Copy link

where does ios/.xcode.env exist, i couldn't find that

@ApoIesh
Copy link

ApoIesh commented Feb 11, 2024

try removing the currently installed Node version and download a different version of Node you could use NVM to manage different versions of Node if you already use it try another version

i solve this error by downgrade my version

@ardacmen
Copy link

it is path issue. just check your ios folders path, if it has empty space please remove it and reindex all project

@skjangid
Copy link

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!!!!!!!!

Thanks, this is worked for me :)

@ashirkhan94
Copy link

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👍

@elibroftw
Copy link

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

This worked on the latest react-native (0.73.5).

@ashirkhan94
Copy link

https://stackoverflow.com/a/66497247
This is my exact issue, resolved by using above answer

@hieu-v
Copy link

hieu-v commented Mar 13, 2024

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

@mbaker3
Copy link

mbaker3 commented Mar 13, 2024

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

@devrmateo
Copy link

devrmateo commented Mar 26, 2024

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

This worked for me.

Same here

@eman747
Copy link

eman747 commented Mar 28, 2024

change index.tsx or index.ts to index.js

@MuhammadUsama2106
Copy link

how i fix for me i have a space in foldername like " app name " in main file after removing the space its start working

@Afiolabi
Copy link

Afiolabi commented Apr 9, 2024

check for spaces as you are naming the project folders. Use space alternatives.

This worked for me

@carlosriveroib
Copy link

carlosriveroib commented Apr 12, 2024

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
Captura de pantalla 2024-04-12 a las 17 37 25

@Afiolabi
Copy link

Afiolabi commented Apr 12, 2024 via email

@carlosriveroib
Copy link

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

@tschoffelen
Copy link

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.

@carlosriveroib have you tried setting the PATH in .xcode.env? I think sometimes RN might ignore the NODE_BINARY env var, but it will look in the PATH to find node. Something like this could help:

export PATH="/usr/local/opt/node@18/bin:$PATH"
export NODE_BINARY=$(command -v node)

(replace /usr/local/opt/node@18/bin with the directory your Node binary is located in, which is visible in your screenshot above)

@anniewey
Copy link

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.

@ustuncem
Copy link

ustuncem commented May 2, 2024

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

@rajkamal-360
Copy link

```diff
+ set +e

this is read only file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests