react-native: [ios, new arch] RN 0.72.0rc5 : React-RCTAppDelegate => Command PhaseScriptExecution failed with a nonzero exit code

Description

When you create a new app using the latest RC for 0.72 and then install pods for new architecture, then the xcode build will fail in React-RCTAppDelegate with Command PhaseScriptExecution failed with a nonzero exit code.

React Native Version

0.72.0.rc5

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 13.4
  CPU: (10) arm64 Apple M1 Max
  Memory: 3.59 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.2.0
    path: /opt/homebrew/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: /Users/paulingalls/.rvm/gems/ruby-3.1.3/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9477386
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.19
    path: /opt/homebrew/opt/openjdk@11/bin/javac
  Ruby:
    version: 3.1.3
    path: /Users/paulingalls/.rvm/rubies/ruby-3.1.3/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.0-rc.5
    wanted: 0.72.0-rc.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

Steps to reproduce

npx react-native@latest init RN0720RC5 --version 0.72.0-rc.5 cd RN0720RC5/ios USE_HERMES=1 RCT_NEW_ARCH_ENABLED=1 pod install --repo-update

Open the xcode workspace and hit build.

Snack, code example, screenshot, or link to a repository

You can just use the starter app with no code changes.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29 (17 by maintainers)

Most upvoted comments

does it happens also if you put the actual path in the .xcode.env file? so, instead of having

export NODE_BINARY=$(command -v node)

you actually have

export NODE_BINARY=~/somewhere/pointing/to/node/executable

basically, you can run command -v node in the terminal and paste the result after NODE_BINARY=

I haven’t dug into it recently, but basically Xcode looks for env vars in specific paths.

Also, before each script exec, it export a bunch of environment variables, which can also clash with the current setup.

Unfortunately, it is kind of a known issue, you can find other people asking how to have Xcode recognise those variables online, but there is no clear explanation why it doesn’t pick them up automatically. ☹️

does it happens also if you put the actual path in the .xcode.env file? so, instead of having

export NODE_BINARY=$(command -v node)

you actually have

export NODE_BINARY=~/somewhere/pointing/to/node/executable

basically, you can run command -v node in the terminal and paste the result after NODE_BINARY=

Following your steps, my machine is already functioning properly

does it happens also if you put the actual path in the .xcode.env file? so, instead of having

export NODE_BINARY=$(command -v node)

you actually have

export NODE_BINARY=~/somewhere/pointing/to/node/executable

basically, you can run command -v node in the terminal and paste the result after NODE_BINARY=

Your solution works, thanks !!

But it leads to another question, why $(command -v node) is not working in the case

OK, I dug into this some more.

tldr; I was installing watchman at roughly the same time with brew, and I’m guessing brew decided it would be a good idea to update my other packages, which included node. So even though node was there, I’m guessing it had problems launching.

I had previously been working on my intel mac with no problems, but moved to my m1 to make sure all was ok. I noticed I didn’t have watchman, so I kicked off the install with brew, then updated my project and tried to pod install, resulting in the error. So I tried some more, googled around a bit, and overall couldn’t find what was up. Then I tried with a clean project from init, with the same result so I filed the bug.

However, during this process watchman was still installing. I believe what happened was that brew decided to upgrade all of the other packages on my mac (is this the default now?). One of those packages was node. So even though node was there, I’m guessing it couldn’t launch properly.

At any rate, when I try in a new folder today, the pod install works and the scripts run.

Sorry for the runaround. Appreciate all you guys do!

Thanks @ajpaulingalls for the full log.

I’ll look into this later today. I always test the new arch and last Thursday, when we released RC.5, it was working, so I’m a bit confused here.

We: have you also tried to disable Hermes? If yes, does the failure remain?

Nit: you don’t need to use the USE_HERMES flag, as that’s is the default! 😉

It’s weird that when I disable New architecture, the node env path was picked correctly

I am facing the same issue in m1 mac

The same error occurred in the latest version(0.72.1) with RCT_NEW_ARCH_ENABLED=1

I’ve just bumped into this issue with RN@0.72.1

image

The Warning in the beginning of the screenshot makes me guess that it actually fails to detect the correct string for node executable command, gets an empty string instead of it, and thus instead of /path/to/node /path/to/generate-legacy-interop-components.js it runs just /path/to/generate-legacy-interop-components.js, where JS script is not meant to be an executable, does not have execute permissions, and that’s why the error reads “Permission denied”.

I actually have .xcode.env file in the project, with export NODE_BINARY=$(command -v node) command inside it, and command -v node returns me the correct path to node when I run it in my regular shell, but when that script is evaluated within XCode build, somehow I checked command -v node returns an empty string.

And… I am still using an Intel Mac, and I have Node installed via NVM, and it seems that something between NVM and XCode broke on my system, and it was highlighted by that script failing. The solution that works for me:

https://blog.nigelsim.org/2022-12-09-nvm-node-from-xcode/

I’m not saying we won’t ever fix it - just that the fix can wait 0.72.1

thanks for the report, I think that since it’s new arch specific we might not consider it 0.72.0 release blocker but worth looking into

It does make using the new architecture basically impossible on a newer model mac…

thanks for the report, I think that since it’s new arch specific we might not consider it 0.72.0 release blocker but worth looking into