Setting up React Native version (0.73.4) environment installing at IOS for macOS Sonoma m2 apple chip , with Xcode 15.2

800 Views Asked by At

React-rncore issues Command PhaseScriptExecution failed with a nonzero exit code

I've been trying to use React Native in a macOS Sonoma m2 chip, with the react-native-cli. Following the documentation of RN setting up the environment for macOS IOS, is not working for me and this is why.

First, I tried the following process.

  • Install Xcode (current version 15.2) and command line tools. Using the command npx react-native init MyProject everything seems to work at the beginning, but when the installing dependencies arrived, it throws “error installing pods”, or sometimes “error installing cocoapods”. And obviously, RN says, “this doesn’t affect the initialization, but you will need to install cocoapods and pods manually”. So I did that.
  • Run cd /MyProject and sudo npm install
  • Run cd /ios and bundle install in my case what it worked was sudo bundle install because it was giving me a permission error.
  • Run bundle exec pod install thanks to the permission error, it worked sudo bundle exec pod install --allow-root
  • Finally we can execute the app in Xcode by opening the .xcworkspace and hitting run. I have to mention that I changed the permissions to read & write in order for me to open the folder, I changed it for .xcworkspace .xcodeproj and inside the /pods folder the permissions for .xcodeproj

Everything installed correctly, but when hitting run in Xcode, the build failed giving me the logs of “Command PhaseScriptExecution failed with a nonzero exit code”. I don’t know if this has to do with the changes I made in the process, like the permissions from point number 4 (I was not able to open the file if I didn’t change permissions) or maybe instead of bundle exec pod install I ran sudo bundle exec pod install --allow-root

I know I can install cocoapods by using Homebrew or Gems, and I tried this:

Run brew install cocoapods or sudo gem install cocoapods Then I saw in some forums that for mac m1/m2 chips, it was necessary to install sudo gem install ffi -n /usr/local/bin Then run in the /ios folder pod install in my case, thanks to permissions errors, it was sudo pod install --allow-root

React Native Version

0.73.4

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.3
  CPU: (12) arm64 Apple M2 Pro
  Memory: 87.56 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.1
    path: ~/.nvm/versions/node/v21.6.1/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v21.6.1/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v21.6.1/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 34.0.0
    System Images:
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 3.3.0
    path: /Users/muhammadhuzaifajunaid/.rubies/ruby-3.3.0/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.4
    wanted: 0.73.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true

Command PhaseScriptExecution failed with a nonzero exit code Build failed

I want run the build at IOS platform with latest with React Native version (0.73.4) for macOS Sonoma m2 apple chip with Xcode 15.2 version

enter image description here

1

There are 1 best solutions below

1
Muhammad Tahir On BEST ANSWER

First remove the space from the parent folder name inside which the react native project place.

For Example: React Native/YourProjectName -> React-Native/YourProjectName

Note: Remove space from folder Name inside which the react native projects place

After removing space from the folder name follow the below steps

  1. Remove Pods and Podfile.lock folder inside ios
  2. Reinstall Pods