Flutter "Command PhaseScriptExecution failed" (xcodebuild, iOS) in CI
xcodebuild runs each target build phase, including the Flutter "Run Script" phase and CocoaPods scripts. When one exits non-zero, Xcode reports "Command PhaseScriptExecution failed with a nonzero exit code" and the actual error is in the script output above.
What this error means
The iOS build ends with "Command PhaseScriptExecution failed with a nonzero exit code". The failing script (Thin Binary, [CP] Embed Pods Frameworks, or xcode_backend.sh) and its error appear earlier in the xcodebuild log.
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks ...
.../Pods-Runner-frameworks.sh: line 1: ... No such file or directory
Command PhaseScriptExecution failed with a nonzero exit codeCommon causes
A pod or Flutter script phase failed
An embed-frameworks script or the Flutter backend script references a path or tool that is missing in CI.
A stale Pods integration after dependency changes
Pods were not reinstalled after a plugin change, so a generated script references frameworks that no longer match.
How to fix it
Read the failing script output
Find which build phase failed and the line it printed before exiting.
cd ios && xcodebuild -workspace Runner.xcworkspace -scheme Runner -configuration Release 2>&1 | tee xcode.logReinstall pods and clean the iOS build
- Run
flutter cleanandflutter pub get. - Run
pod installinios/to regenerate the script phases. - Rebuild so the embed scripts match the current pods.
flutter clean && flutter pub get
cd ios && pod installHow to prevent it
- Run pod install after every plugin or dependency change.
- Keep the iOS build output to inspect failing script phases.
- Pin Xcode and CocoaPods versions for reproducible script phases.