BugMedic

Command PhaseScriptExecution failed with a nonzero exit code: find the failing script

A generic build failure meaning one of your target's Run Script phases exited with an error; find which script failed and read its own output to fix the real cause.

By BugMedic editorial teamLast source review: 2026-09-27macOS

PhaseScriptExecution is Xcode's generic label for a failed Run Script build phase. Expand that phase's section in the build log and read its last output lines — the script's own message names the real cause, which is usually a missing tool, a bad path, or an environment problem.

Try these fixes in order

01

Open the failing script's own output

PhaseScriptExecution only tells you which script phase failed, never why. In the Report navigator, open the failed build, find the entry named after the script (for example '[CP] Check Pods Manifest.lock' or 'Bundle React Native code and images'), expand it, and scroll to the end. The failing command's own error message is printed there and is the actual problem to fix.

02

Reproduce the failing command in Terminal

Copy the failing command from the log and run it yourself in Terminal from the project directory. If it fails there too, the problem is the command itself — a missing tool, a path that moved, or a file without execute permission — and not an Xcode setting. Fix the command until it succeeds in Terminal before rebuilding in Xcode.

pwd
ls -la .xcode.env
03

For React Native: point NODE_BINARY at your Node

Since React Native 0.69, the ios/.xcode.env file configures the environment of Xcode's build phases. If the bundle script fails because it cannot find node, create or edit ios/.xcode.env and export NODE_BINARY pointing at your Node installation, which is the customization React Native's documentation recommends when you use a version manager.

command -v node
cat .xcode.env
04

For CocoaPods on Xcode 14.3+: update CocoaPods

If the failing phase is a CocoaPods script and its output mentions rsync or resolving symlinked sources, update to CocoaPods 1.12.1 or newer, which fixed this failure on Xcode 14.3 by passing -f when resolving the path to a symlinked source with readlink. Re-run pod install after updating so the generated scripts are regenerated.

pod --version
gem install cocoapods
05

Rebuild and confirm the phase exits zero

Rebuild the same scheme and destination. The build succeeds when the named script exits zero; confirm in the log that the previously failing phase now shows a checkmark. If it still fails, the phase's new output — not the generic PhaseScriptExecution line — is what you iterate on next.

Interpret what you see

The log shows the phase name but no obvious cause

What it suggests: The generic wrapper hides the real failure, which the script itself printed just above.

Next check: Expand the build log entry for that script and read its last output lines before touching any settings.

The script output mentions a missing command, such as node, python3, or a gem binary

What it suggests: The script depends on a command-line tool that is installed for your login shell but not visible to Xcode's build environment.

Next check: In Terminal, run the script's command manually from the project directory to reproduce the missing-tool error.

The failing script is a CocoaPods script ([CP] ...) and the output mentions rsync or readlink

What it suggests: CocoaPods versions before 1.12.1 resolve symlinked sources without the -f flag, which breaks under Xcode 14.3.

Next check: Run pod --version; if it is below 1.12.1, update CocoaPods and run pod install again.

Why this happens

  • The named Run Script phase's own command failed (missing tool, wrong path, denied permission, bad environment variable). Xcode reports the phase as the failure point but the underlying cause is whatever the script printed just before the error.
  • A known toolchain interaction: CocoaPods versions below 1.12.1 ship an rsync-based embed script that fails under Xcode 14.3's handling of symlinked sources; separately, React Native builds fail when Xcode's build environment cannot find Node, which React Native 0.69+ addresses through the .xcode.env file's NODE_BINARY export.

Still not working?

If the steps fail, collect the exact failing command from the phase log (target > Build Phases > the named script), the last 20 lines of that phase's output, your Xcode version, and whether the same command fails when pasted into Terminal from the project directory. For React Native projects also record the contents of ios/.xcode.env and the output of the NODE_BINARY path. For CocoaPods projects record pod --version and whether the failure names an rsync or readlink line.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related Xcode guides