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 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.
shell
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.
Related guides
xcrun "unable to find utility" in CIFix xcrun "unable to find utility" in CI by selecting a full Xcode toolchain instead of the standalone Comman…
xcodebuild "Unable to load contents of file list" in CIFix xcodebuild "Unable to load contents of file list" in CI, usually a missing CocoaPods xcfilelist, by runni…
CocoaPods "sandbox is not in sync with the Podfile.lock" in CIFix the CocoaPods "sandbox is not in sync with the Podfile.lock" error in CI by running pod install so the co…