facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.75k stars 24.29k forks source link

Command PhaseScriptExecution failed with a nonzero exit code - Error when Archive on Xcode 14.3 #36762

Open leofolive opened 1 year ago

leofolive commented 1 year ago

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

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

elibroftw commented 7 months ago

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.

ashirkhan94 commented 7 months ago

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

hieu-v commented 7 months ago

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

mbaker3 commented 7 months ago

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

devrmateo commented 6 months ago

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 commented 6 months ago

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

UsamaScripts commented 6 months ago

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 commented 6 months ago

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

This worked for me

carlosriveroib commented 6 months ago

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 commented 6 months ago

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 https://github.com/facebook/react-native/issues/36762#issuecomment-2052395683, or unsubscribe https://github.com/notifications/unsubscribe-auth/A27O777YYJ5BQA2BNGMPN6LY5AXYLAVCNFSM6AAAAAAWQOXYUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGM4TKNRYGM . You are receiving this because you commented.Message ID: @.***>

carlosriveroib commented 6 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago
```diff
+ set +e

this is read only file

themohitkhandal commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago
  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 commented 5 months ago

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

in your project/ios folder

rajkamal-360 commented 5 months ago

To reveal hidden files press Command + Shift + .(the period key) and then perform your operations.

On Fri, 17 May 2024 at 9:40 PM, Chidera Paul Ugwuanyi < @.***> wrote:

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

in your project/ios folder

— Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/36762#issuecomment-2117928917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZGM2PJLIZY7KTO6ZPNR4LTZCYTYDAVCNFSM6AAAAAAWQOXYUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJXHEZDQOJRG4 . You are receiving this because you commented.Message ID: @.***>

fellenabmb commented 4 months ago

Issue present here too.

"react-native": "0.72.4",

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

maya-salcedo commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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

sahilrathi01 commented 2 months ago

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

This works for me

saracasticshailz commented 2 months ago

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

jasimchz commented 2 months ago

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

umer-viabletree commented 2 months ago

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

rawatnaresh commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

This work for me

dinoDanic commented 1 month ago

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

athaljen commented 1 month ago

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 commented 1 month ago

this worked for me:

delete ios folder

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

yunusaslancan commented 4 weeks ago

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

scottmsul commented 2 weeks ago

Also I found compiling from the command line (eg yarn ios) can sometimes give better debug info than clicking play from the xcode UI (not sure how to access the failure logs from inside of xcode).

ChandramaniPatel commented 1 week ago

I have resolved the issue on both Machine Intel mac(MacOS 13.6 and Xcode15) as well as on Silicon M3 chip(MacOS 14.6 and Xcode 16) . for me , it was a space between name of one outer directory . for eg it was like:- ABC DEF/KK/MM. space should be removed Between ABC and DEF , So I did ABC_DEF/KK/MM So the step I taken -

  1. renamed the dir which were having space in name like ABC_DEF/KK/MM
  2. Go to terminal and run the pod deintegrate under your project
  3. now run the pod install
  4. Clean the build on xcode
  5. delete the derrived data of xcode