Skip to content

Getting Command PhaseScriptExecution failed with a nonzero exit code while running in iOS #74

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

Closed
Shahanshah-TA opened this issue Apr 24, 2024 · 4 comments

Comments

@Shahanshah-TA
Copy link

Shahanshah-TA commented Apr 24, 2024

Trying to run a RN app to iOS. If I build a bare-bones RN app I can get this running in a simulator without issue. The moment I add nodejs-mobile the application no longer compiles.

Versions:
NodeJS 20.12.2 (I have also tried with Node 18.20.2 & 16.20.2)
RN 0.71.8
nodejs-mobile 18.17.7 (I have also tried with 18.17.6)
iOS Simulator 17.4

Install process

npx react-native init projectName
cd projectName
npm start > i (Install cocoapods)
(Confirm the installation operates on iOS Simulator, exit Metro server)
npm i nodejs-mobile-react-native
cd ios
pod install
cd ..
npm start > i (build new iOS app, hangs, build logs below)

I have tried deleting the DerivedData, /ios/pod & pod install, /ios/build, removing the /node_modules & npm install, deleting the apps on the simulator. I have also tried downgrading RN and nodejs-mobile. Restarting the Mac, restarting Terminal.

react-native info

System:
    OS: macOS 14.4.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 52.61 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - /var/folders/bz/bnbsm_9x5z56hd5mz_pdpv0h0000gp/T/yarn--1713938949460-0.9874166888650591/node
    Yarn: 1.22.21 - /var/folders/bz/bnbsm_9x5z56hd5mz_pdpv0h0000gp/T/yarn--1713938949460-0.9874166888650591/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.4, iOS 17.4, macOS 14.4, tvOS 17.4, visionOS 1.1, watchOS 10.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2023.2 AI-232.10227.8.2321.11479570
    Xcode: 15.3/15E204a - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.10 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.8 => 0.71.8 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Any assistance is appreciated! @staltz @jmatsushita @jaimecbernardo

@staltz
Copy link
Member

staltz commented Apr 24, 2024

The moment I add nodejs-mobile the application no longer compiles.

Please share the errors you see, they give vital hints on what's going wrong. Without knowing what's wrong, it's hard to fix something.

@Shahanshah-TA
Copy link
Author

Shahanshah-TA commented Apr 24, 2024

Fixed it. Issue was it was using some other node version (I guess 20+). I created .xcode.env.local and added

. "$(brew --prefix nvm)/nvm.sh"
nvm use 18

Now its working fine.
Thanks for your response. I will ping I will face any issue in deployment. Closing this for now.

@Shahanshah-TA
Copy link
Author

Shahanshah-TA commented Apr 24, 2024

@staltz I make it to work with above solution.
I did add .xcode.env.local in ios folder in vs code (not in xcode) and with command react-native run-ios its working fine.
But when I am trying to run it from Xcode getting the same error Command PhaseScriptExecution failed with a nonzero exit code, I think Xcode is having another node version. Anything which I am doing wrong because of that xcode is not recognizing my .xcode.env.local file.

@staltz
Copy link
Member

staltz commented Apr 24, 2024

Good that you discovered the underlying problem.

Xcode just sometimes misbehaves. I wish I had a better answer, but given that it's such an opaque tool (not open source), we can't dig deeper. I would recommend restarting your computer, cleaning all possible caches, deleting the project's "build" folder that is usually in Application Support folder, and then trying again.

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

No branches or pull requests

2 participants