Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Archive Fails for React Native Project – "Run custom shell script 'Bundle React Native code and images'"

I am working on a React Native project, and while building the project in Xcode works fine, for releasing the app to app store, and archiving it fails with the following error:

Command PhaseScriptExecution failed with a nonzero exit code

This error occurs in the "Run custom shell script 'Bundle React Native code and images'" phase.

Details:

  • Xcode Version: 16.0 (16A242d)
  • Node Version: /opt/homebrew/bin/node (Output from which node)
  • React Native Version: 0.74.3
  • macOS Version: 15.0.1 (24A348)

Build Phase Script:

Here’s the script currently in the "Bundle React Native code and images" phase:

set -e

WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"

What I’ve Tried:

  1. Checked for the existence of with-environment.sh and react-native-xcode.sh in node_modules/react-native/scriptsThe scripts folder is missing.

  2. Reinstalled node_modules using npm install and yarn install – no change.

  3. Verified that $REACT_NATIVE_PATH is empty when echoed.

  4. Updated the script to directly use:

    export NODE_BINARY=/opt/homebrew/bin/node
    ../node_modules/react-native/scripts/react-native-xcode.sh
    

    – This didn’t solve the issue.

  5. Cleaned the build folder in Xcode and removed DerivedData.

  6. Ran pod install --repo-update in the ios directory.

Additional Information:

  • Error occurs only during the archive process, not during a regular build.
  • I checked the version-specific documentation and couldn't find a clear solution.

Question:

  • Has anyone encountered this issue where the scripts folder is missing in node_modules/react-native?
  • Is there a known fix or workaround to make the archive step succeed?

Any help or pointers would be greatly appreciated!

I have tried multiple solutions that GPT suggested but nothing got fixed unfortunately :(

Alot of other stackoverflow answers suggested this fix but this was already fixed in my code by default:

update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, need to replace:

source="$(readlink "${source}")"

with

source="$(readlink -f "${source}")"

like image 446
Sohaib Bin Mohsin Avatar asked Oct 15 '25 19:10

Sohaib Bin Mohsin


1 Answers

I came across the same error too, here's how to actually debug the issue

  • Identify the failing script phase, which in my case is the "Bundle React Native code and images."
  • Expand the error log to view detailed steps. (click on hamburger menu to the right of script phase) List item
  • Scroll down to locate the specific error message.

in my case it was this Error: Unable to resolve module ../../../../assets/icons/BullseyeIcon

Fix any missing assets or incorrect paths in your code attempt to Archive the project again Goodluck!

like image 179
Tosin Ola Avatar answered Oct 18 '25 16:10

Tosin Ola



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!