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 · 141 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
Contributor

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
Contributor

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

@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

@themohitkhandal
Copy link

I fixed this. Actually in my case there was a wrong import of a file. In my react native app I have a HomeStack where all my screens are imported. I fixed the file name there and it worked all good.

@harvin123
Copy link

harvin123 commented May 8, 2024

Some times these kind of issues arises when our app project folder or folder containing our app has space in naming. Always try to have _ in the project naming. I had the similar issue i tried everything related to pod clean, cache clean, Derived Data clean, restart as well. The issue i had with folder naming "app projects/mobile_app" . When i updated it "app_Projects/mobile_app" it fixed the issue. Thanks

@Ahsanali012
Copy link

Same issue with React Native "0.72.3" and xcode 15.3 and M1. I already tried above solution but none worked. Please suggest solution

@mufaawan
Copy link

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

Thank you it solved my issue, But if someone has space in the path, it needs to be fixed with \ . For example my path had space in it. I made it work like this. export NODE_BINARY=/Users/umarfarooq/Library/Application\ Support/Herd/config/nvm/versions/node/v21.7.3/bin/node

@haykaslanyan13
Copy link

haykaslanyan13 commented May 17, 2024

  1. Create ios/.xcode.env.local file.
  2. Add this line - export NODE_BINARY=/Users/myuser/.nvm/versions/node/v21.7.3/bin/node
    Note: You can find your NODE_BINARY by running the which node command.

@dexiouz
Copy link

dexiouz commented May 17, 2024

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

in your project/ios folder

@rajkamal-360
Copy link

rajkamal-360 commented May 21, 2024 via email

@fellenabmb
Copy link

fellenabmb commented May 24, 2024

Issue present here too.

"react-native": "0.72.4",

It started out of the blue after updating xcode, basically.

@maya-salcedo
Copy link

Thanks @rdnsan

try this, it worked for me

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

This works for me and it does not generate the ios/.xcode.env.local file.

@batuhanbag
Copy link

also you can try to delete ios/.xcode.env.local file and pod install again, I tried this and build again its solved for me

@yushanwebdev
Copy link

Thanks @batuhanbag

also you can try to delete ios/.xcode.env.local file and pod install again, I tried this and build again its solved for me

This worked for me

@c-info
Copy link

c-info commented Jun 11, 2024

Solved by the below steps (in MAC)

1 remove ios/.xcode.env.local
2 pod deintegrate
3 rm -rf build/
4 rm Podfile.lock
5 pod install

@scottmsul
Copy link

scottmsul commented Jun 20, 2024

I found these steps below to consistently resolve this error. What's strange is I started getting this error for completely new/empty RN projects, and only recently. To resolve it I had to attempt to build the project first in xcode, have it fail, then do all these steps, then it would work the second time. Doing these steps in this order before the first build didn't seem to work. This was using RN 0.73.8 and node 20. I didn't try to test each step individually, so maybe it can be simplified.

cd ios
rm .xcode.env.local
rm .xcode.env
pod deintegrate
rm -rf ./build
rm Podfile.lock
cd ..
rm -rf ./node_modules
npm install
cd ios
pod install
open xcode
Product -> Clear all issues
Product -> Clean build folder
click play

@swankhede
Copy link

i had same issue i fix it by changin path of node binary in .xcode.env
you can try in
# ios/.xcode.env
add this line
export NODE_BINARY=$(which node)
no need to delete pod just clean and run it

@javidmammad
Copy link

javidmammad commented Jul 23, 2024

deletion of ".xcode.env.local" was only solution for me

@sahilrathi01
Copy link

deletion of ".xcode.env.local" was only solution for me

This works for me

@saracasticshailz
Copy link

node_modules/react-native/scripts
You’re saver.

@jasimchz
Copy link

jasimchz commented Aug 5, 2024

In my case, I deleted .xcode.local.env in ios folder and clean project and build agians worked

@umer-viabletree
Copy link

delete ios/.xcode.env.local file and install pod again it work my side

@rawatnaresh
Copy link

In my case I had to create ios/.xcode.env.local and add
export NODE_BINARY=/Users/username/.nodenv/versions/20.16.0/bin/node

@ziggear
Copy link

ziggear commented Aug 8, 2024

Hello everyone, if you encounter errors in Xcode during the "[CP] Embed Pods Frameworks" phase, and have ruled out issues with the ".xcode.env" file, as well as upgraded to CocoaPods version 1.12, you might want to check out my solution.

I found that the root cause was that both the rsync and codesign commands failed during the "[CP] Embed Pods Frameworks" phase. The issue was actually due to permission problems caused by the User Script Sandboxing parameter in Xcode's Build Settings. Setting User Script Sandboxing to NO resolved the issue for me.

image

My environment info:

macOS 14.4.1 
Xcode 15.0.1
cocoapod 1.12.0
node v18.20.4
react native 0.75.0-rc.6

@KuiGoan
Copy link

KuiGoan commented Aug 10, 2024

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

This work for me

@dinoDanic
Copy link

this worked for me:
delete ios folder
run npx expo prebuild

@athaljen
Copy link

athaljen commented Sep 3, 2024

This also happened to me. Init project on M1, Xcode 14.3, React-Native 0.72.6 Check the path to where your project is located and make sure there aren't any folders with spaces in the name. Error: /Users/username/Documents/My Team/MyApp just update to: /Users/username/Documents/MyTeam/MyApp

I am also facing the same issues, create new project then when i run the project same issues.

Tried all like:

changing NODE_BINARY path
deleting .xcode.env.local
set -e
set +e ...etc.

None of the above work.

But like you have said i just remove the space in my folder worked.
Before : /Users/athaljen/Desktop/React Native/testApp
After: /Users/athaljen/Desktop/React-Native/testApp

Thanks.

@jasimchz
Copy link

jasimchz commented Sep 3, 2024

this worked for me:

delete ios folder

run npx expo prebuild
Are you kidding, Delete Ios folder?

@yunusaslancan
Copy link

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

Yes, This work for me

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