# Xcode: Command PhaseScriptExecution failed with a nonzero exit code

**Code:** `PhaseScriptExecution` · **Category:** iOS · **Seen on:** iOS

A Run Script build phase (CocoaPods, React Native, Flutter, SwiftLint, Crashlytics…) failed. The real error is above this line in the build log.

## Meaning

Xcode only reports that a script failed. Open the Report navigator, expand the failing “Run custom shell script” step and read its output.

## Common causes

- CocoaPods out of sync (`Pods/Manifest.lock` mismatch)
- Node not found by Xcode (React Native) — PATH differs from your shell
- Flutter/Dart tool path or version issues
- Script lacks execute permission or has CRLF line endings
- User Script Sandboxing (Xcode 15+) blocking file access

## Quick fix

1. Expand the failing step in the Report navigator
2. `cd ios && pod install`
3. React Native: set `NODE_BINARY` in `ios/.xcode.env.local`
4. Try `ENABLE_USER_SCRIPT_SANDBOXING = NO` for scripts that need file access
5. Clean build folder (⇧⌘K) and DerivedData

## Detailed fix by platform

### iOS

1. React Native Node path:

```bash
echo "export NODE_BINARY=$(command -v node)" > ios/.xcode.env.local
cd ios && pod install
```


## How to diagnose

1. **Script** — Which build phase failed?
2. **Output** — What did it print before exit?
3. **Environment** — PATH/tools visible to Xcode?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ios/command-phasescriptexecution-failed)
