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

React native ios: Showing Recent Errors Only Command PhaseScriptExecution failed with a nonzero exit code #41617

Closed
mohreRohan1 opened this issue Nov 23, 2023 · 13 comments
Labels
Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Newer Patch Available Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@mohreRohan1
Copy link

Description

I am getting below issue while buuilding react native project from xcode:

stackover

tried removing the podfile.lock, Pods folder and did 'pod install' as well, but no luck.

Also, when i am running the application from terminal using the command 'npx react-native run-ios', getting below error:
4

React Native Version

"react-native": "0.72.4",

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 13.6
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 866.93 MB / 16.00 GB
Shell:
version: 3.2.57
path: /bin/bash
Binaries:
Node:
version: 20.8.0
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.8.1
path: /usr/local/bin/npm
Watchman:
version: 2023.10.02.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /Users/admin/.rvm/gems/ruby-3.2.1/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK:
API Levels:
- "30"
- "33"
- "34"
Build Tools:
- 29.0.2
- 30.0.2
- 30.0.3
- 33.0.0
- 33.0.1
- 34.0.0
System Images:
- android-31 | Google Play Intel x86_64 Atom
- android-33 | ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
- android-34 | Google APIs Intel x86_64 Atom
- android-TiramisuPrivacySandbox | Google Play Intel x86_64 Atom
Android NDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.10811636
Xcode:
version: 15.0.1/15A507
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.6
path: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/javac
Ruby:
version: 3.2.2
path: /usr/local/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: ^18.2.0
react-native:
installed: 0.72.4
wanted: 0.72.4
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: Not found

Steps to reproduce

run 'npx react-native run-ios'

and

build from xcode

Snack, screenshot, or link to a repository

4
@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Nov 23, 2023
Copy link

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

Copy link

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.72.7. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@liquidvisual
Copy link

I ran into this too, when I upgraded to Sonoma and XCode 15. I can get my project working in an iPhone simulator but it throws this error on a real device. Nightmare.

@liquidvisual
Copy link

liquidvisual commented Nov 23, 2023

I managed to solve it. In my case it was my version of Node 21.2.0 not having access to openSSL (I have no clue what it is/does but it's legacy now).

In XCode under Build Phases => Bundle React Native code and images, I added an additional export with a flag for openssl-legacy-provider:

set -e

export NODE_BINARY=node
export NODE_ARGS="--openssl-legacy-provider" # <~~~~~~ ADDED HERE
../node_modules/react-native/scripts/react-native-xcode.sh

After this, I was able to build and archive with XCode normally. 🥳


EDIT: to get it working in the simulator with npx react-native run-ios I needed to make this change:

node_modules/react-native/scripts/find-node.sh @ L7:

set +e

Source


Note: Android has a similar issue with building, eg cd android && ./gradlew assembleRelease, to fix that the simplest thing was to add a .npmrc file in the root of my project with the following:

node-options="--openssl-legacy-provider"

Also note: don't add this to your .zshrc / .bash_profile otherwise VSCode will have Shell problems. source


UPDATED:

The above eventually failed to work in dev, instead I now run the metro server via npm script in my package.json, and install onto the physical Android device afterward. Seems to work for me:

"scripts": {
  "1. start-metro-server": "export NODE_OPTIONS=--openssl-legacy-provider && react-native start",
  "2. android": "react-native run-android"
}

@Anand013
Copy link

Click properties on the project, go to build phases and check the option
"For install builds only"

@cipolleschi
Copy link
Contributor

Hi @mohreRohan1.
Your issue is related to a Script Phase that is failing, but the error is not explicative. To get more information, can you click on the five horizontal lines on the right (see pic below)?

285109345-1b005229-875c-4c42-b3e4-5824b2bd9844

Also, from the image, the script is owned by Expo, not by React Native core, as you can see by the string:

Run custom Shell script **[Expo] Configure Project**
285109345-1b005229-875c-4c42-b3e4-5824b2bd9844

Can you open an issue in their repo? They will be better equipped to help you.

@night-fury-rider
Copy link

I was facing similar issue. In my case it was happening since my machine was having 2 node versions installed. Following anwser helped me resolve this issue:

https://stackoverflow.com/questions/44492197/react-native-ios-build-cant-find-node/50419734#comment136800082_50419734

@nochkin
Copy link

nochkin commented Dec 7, 2023

@mohreRohan1
Your screenshot has "Your session has expired. Please login" error message.
I think you just need to login to your Apple Dev account from Xcode Preferences.

@efstathiosntonas
Copy link

efstathiosntonas commented Dec 18, 2023

This commit fixed it for me: (rn 0.73.0)

9f28616

I was getting this back:

Command PhaseScriptExecution failed with a nonzero exit code


Node found at: /Users/stathis/.nvm/versions/node/v18.17.1/bin/node
+ DEST=/Users/stathis/Library/Developer/Xcode/DerivedData/xxxxxxxxxxj/Build/Products/Debug-iphoneos/xxxxxxxxx.app
+ [[ ! -n '' ]]
+ [[ Debug = *Debug* ]]
+ [[ ! iphoneos == *simulator ]]
+ for num in 0 1 2 3 4 5 6 7 8
++ ipconfig getifaddr en0
+ IP=
Command PhaseScriptExecution failed with a nonzero exit code

The IP= was empty so after running this on my terminal ipconfig getifaddr en0 it returned nothing while ipconfig getifaddr en1 returned my machine's IP address. After visiting react-native/scripts/react-native-xcode.sh on this repo I found out about the commit mentioned above that fixed it for me.

Worth mentioning that the build error was happening only when building on real device, on simulator the build has no issues.

@rafaels-dev
Copy link

This commit fixed it for me: (rn 0.73.0)

9f28616

I was getting this back:

Command PhaseScriptExecution failed with a nonzero exit code


Node found at: /Users/stathis/.nvm/versions/node/v18.17.1/bin/node
+ DEST=/Users/stathis/Library/Developer/Xcode/DerivedData/xxxxxxxxxxj/Build/Products/Debug-iphoneos/xxxxxxxxx.app
+ [[ ! -n '' ]]
+ [[ Debug = *Debug* ]]
+ [[ ! iphoneos == *simulator ]]
+ for num in 0 1 2 3 4 5 6 7 8
++ ipconfig getifaddr en0
+ IP=
Command PhaseScriptExecution failed with a nonzero exit code

The IP= was empty so after running this on my terminal ipconfig getifaddr en0 it returned nothing while ipconfig getifaddr en1 returned my machine's IP address. After visiting react-native/scripts/react-native-xcode.sh on this repo I found out about the commit mentioned above that fixed it for me.

Worth mentioning that the build error was happening only when building on real device, on simulator the build has no issues.

I replaced the entire for with a new command to get local IP of ethernet address without need to run through a loop, and worked fine to me.

IP=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | head -1 | awk '{ print $2 }')
  # 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

@tonyjohnvan
Copy link

This commit fixed it for me: (rn 0.73.0)

9f28616

I was getting this back:

Command PhaseScriptExecution failed with a nonzero exit code


Node found at: /Users/stathis/.nvm/versions/node/v18.17.1/bin/node
+ DEST=/Users/stathis/Library/Developer/Xcode/DerivedData/xxxxxxxxxxj/Build/Products/Debug-iphoneos/xxxxxxxxx.app
+ [[ ! -n '' ]]
+ [[ Debug = *Debug* ]]
+ [[ ! iphoneos == *simulator ]]
+ for num in 0 1 2 3 4 5 6 7 8
++ ipconfig getifaddr en0
+ IP=
Command PhaseScriptExecution failed with a nonzero exit code

The IP= was empty so after running this on my terminal ipconfig getifaddr en0 it returned nothing while ipconfig getifaddr en1 returned my machine's IP address. After visiting react-native/scripts/react-native-xcode.sh on this repo I found out about the commit mentioned above that fixed it for me.

Worth mentioning that the build error was happening only when building on real device, on simulator the build has no issues.

Thanks very much for the info! got mine fixed right away 👍
the issue is that I can see the facebook codebase has this fixed and merged, however for the npm (node@18) and yarn installed package react-native@0.73.0 the file inside node_modules seems still be the old code... and to fix the building issue I have to manually modify the node_modules/react-native/scripts/react-native-xcode.sh for test on real device.

@cipolleschi
Copy link
Contributor

@tonyjohnvan Thanks for reporting this. We have a pick request process for 0.73 in this discussion.

This time, I added the pick request myself, in this message.

Feel free to submit a pick request directly, next time! :D

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Newer Patch Available Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

9 participants