Software⏱️ 4 min read📅 2026-06-04

How to Fix: Command PhaseScriptExecution failed with a nonzero exit code while trying to add Flutter to iOS app

Flutter iOS app build phase error: Command PhaseScriptExecution failed with a nonzero exit code.

Quick Answer: Check the Xcode console for more detailed information about the error and ensure that the Flutter SDK is properly configured in your project.

The error 'Command PhaseScriptExecution failed with a nonzero exit code' occurs when there is an issue with the script execution during the build phase of your Xcode project. This error affects developers who are trying to add Flutter to their existing iOS apps and need to resolve it before proceeding with the development process.

This frustrating error can be caused by various factors such as missing or incorrect dependencies, syntax errors in the build phase script, or issues with the Xcode environment. In this guide, we will walk you through the steps to troubleshoot and fix this issue.

⚠️ Common Causes

  • The primary reason for this error is that the build phase script is not correctly configured or has syntax errors. The script is responsible for executing the Flutter installation process, but if it fails, the build phase will fail as well.
  • Another possible cause of this error is that there are missing or incorrect dependencies in the project. Make sure to check the project's dependencies and update them if necessary.

✅ Best Solutions to Fix It

Configuring the Build Phase Script

  1. Step 1: Step 1: Open your Xcode project and navigate to the target settings by clicking on the project navigator and selecting the target. Then, click on the 'Build Phases' tab in the target settings.
  2. Step 2: Step 2: In the build phase script section, delete any existing scripts and add a new one by clicking the '+' button at the top left corner of the screen. Select 'Add Build Action' and choose 'Product Script'.
  3. Step 3: Step 3: Create a new file named `FlutterSetup.sh` in the root directory of your project with the following content: #!/bin/bash echo "flutter config --no-verify" flutter doctor -v --debug flutter pub get

Checking Dependencies and Xcode Environment

  1. Step 1: Step 1: Open the Terminal app on your Mac and navigate to the project directory. Run the command `flutter doctor -v` to check for any dependencies issues.
  2. Step 2: Step 2: Check if you have the latest version of Xcode installed by running the command `xcode-select --version`. If not, update Xcode to the latest version.
  3. Step 3: Step 3: Verify that all the required dependencies are installed by checking the project's `.pubspec.yaml` file. Run the command `flutter pub get` to install any missing dependencies.

✨ Wrapping Up

By following these steps and troubleshooting the error, you should be able to resolve the 'Command PhaseScriptExecution failed with a nonzero exit code' issue and successfully add Flutter to your iOS app. Remember to always check your project's configuration and dependencies before proceeding with the development process.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions