Skip to content
Latchkey

xcodebuild "Command PhaseScriptExecution failed" in CI

A Run Script build phase exited nonzero. Xcode reports the phase failure, but the real cause is in that script: a missing tool, a bad path, or a non-zero command.

What this error means

The build fails with Command PhaseScriptExecution failed with a nonzero exit code. The script that failed is named just above the error in the log.

xcodebuild
Command PhaseScriptExecution failed with a nonzero exit code
    /bin/sh -c .../Script-1234.sh
    line 3: swiftlint: command not found

Common causes

A tool used by the script is not on the runner

Scripts that call swiftlint, swiftgen, or other tools fail if the tool is not installed on CI.

Path or environment differs from your machine

The script assumes a path or env var that exists locally but not on the runner.

How to fix it

Read the script log and install missing tools

  1. Scroll up to the exact line the script failed on.
  2. Install the missing tool in a setup step, or guard the script when the tool is absent.
shell
if ! command -v swiftlint >/dev/null; then
  echo "swiftlint not installed; skipping"; exit 0
fi
swiftlint

Make the script CI-aware

Avoid hardcoded local paths; resolve tools via PATH and fail with a clear message so CI logs point at the real cause.

How to prevent it

  • Install all script-phase tools in the runner setup and avoid machine-specific paths. Pre-baked managed runner images that already include common iOS tooling reduce these failures.

Frequently asked questions

What causes ""PhaseScriptExecution failed""?
Scripts that call swiftlint, swiftgen, or other tools fail if the tool is not installed on CI.
How do I fix "PhaseScriptExecution failed"?
Read the script log and install missing tools

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card