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.
Command PhaseScriptExecution failed with a nonzero exit code
/bin/sh -c .../Script-1234.sh
line 3: swiftlint: command not foundCommon 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
- Scroll up to the exact line the script failed on.
- Install the missing tool in a setup step, or guard the script when the tool is absent.
if ! command -v swiftlint >/dev/null; then
echo "swiftlint not installed; skipping"; exit 0
fi
swiftlintMake 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.