Fixed: Error “PhaseScriptExecution failed with a nonzero exit code”
A quick guide covering what the Xcode error "PhaseScriptExecution failed with a nonzero exit code" means and the steps needed to resolve it. Since 2014, over 1.7 million apps have been built using Median.co. If you’re building on our platform, our team of experts are available to assist in fixing this error if your at-home troubleshooting doesn't work. Read more below.
What is the error “PhaseScriptExecution failed with a nonzero exit code”?
If you've hit this error, you already know how disorienting it is. The error itself simply means one of your build scripts didn't finish cleanly and failed. But this error message covers a lot of ground; a “PhraseScriptExecution failed with a nonzero exit code” error can point to a number of different failures.
We built this guide to help other engineers save time, so keep reading if you’ve hit this issue or want to be prepared for the day you do.
Where does the PhaseScriptExceution error come from?
This error can come from missing dependencies, a stale build cache, an outdated CocoaPods setup, or an architecture mismatch between your Mac and the binary the script is trying to run.
To resolve this, you first need to review the build logs to identify the specific script that caused the failure.
Enter any URL to build your iOS app
How can I fix the error “PhaseScriptExecution failed with a nonzero exit code”?
Again, this error can be due to several things. With an error as complicated as this, our team of experts has devised simple steps to fix it promptly:
1. Clear build cache by Xcode > Product > Clean Build Folder.


If troubleshooting the error on your own doesn’t work (even though this fix should typically do it), Median is here to assist.
With an error as complicated as this, our team of experts has devised simple steps to fix it promptly:
1️. Clear build cache by Xcode > Product > Clean Build Folder.

2️. Reinstall Pods by deleting Podfile.lock and the Pods folder. Run the following commands in the terminal.

3️. In cases where the error persists, go to the Report Navigator to find more information about the error and search for potential solutions from there.

If trying to troubleshoot the error on your own doesn’t work (even though it typically should), then Median is here to assist.
Want to know how it all works?
Get hands-on with Median’s comprehensive documentation, and build your app with ease.
How Median helps iOS app developers
Median's Common Xcode Issues guide covers this error and others you're likely to run into.
Apple's Xcode resources are also worth bookmarking if you're working through build configuration issues more broadly.
Additional Xcode errors to look out for
Error 1: "Use of undeclared identifier" or "'ModuleName-Swift.h' file not found."
This error occurs when Objective-C files can't access Swift code due to improper bridging between Swift and Objective-C.
It commonly happens in mixed-language projects where Objective-C files need access to Swift code but can't locate the automatically generated bridging header.
Here are the steps to a possible fix to this error:
Create or update the bridging header: Create a new header file and name it YourProjectName-Bridging-Header.h (if it doesn't already exist).
Add the bridging header to build settings: Open Build Settings, search for Objective-C Bridging Header, then set its path to the bridging header file (YourProjectName/YourProjectName-Bridging-Header.h).
Import the Swift-generated header to your Objective-C files: #import "YourProjectName-Swift.h"
Clean and build to ensure the changes take effect.
If the error persists, Median offers a custom development service to fix it, by either directly fixing the bridging setup or by converting your Swift code to Objective-C (which will remove the need for a bridging header entirely).
Error 2: "Symbol not found: __ZN5swiftXswiftYoverride_conformsToSwiftProtocol..."
This error occurs when building or running a project that has dependencies compiled with an older Swift version or a lower iOS deployment target than the one specified in the project.
It can also occur if Bitcode is enabled for your project, but the dependencies or libraries you're using aren't Bitcode-compatible.
Here are the steps to a possible fix to this error:
Ensure your iOS Deployment Target is compatible across your project and dependencies
Go to Build Settings > iOS Deployment Target.
Make sure the deployment target for your project is not higher than the target of your dependencies.
If any dependency's target is lower, update it to match the project's deployment target.
Verify Swift version compatibility
Go to Build Settings > Swift Language Version to view the swift version.
Update any dependencies to be compatible with the Swift version.
Check for Bitcode compatibility and disable Bitcode if necessary
Go to Build Settings > Enable Bitcode and set it to No for both the project and all relevant dependencies (if they're not Bitcode-compatible).
At Median, we provide custom development to ensure libraries are always up to date with the latest Swift versions and iOS deployment targets. We can also assist with stripping Bitcode in the project and offer further custom fixes.
Instant app store facelift. No designer required.
Unlock Median’s 500+ free Figma app store screenshot templates designed to meet iOS and Android guidelines. Your app will look its best across platforms, resulting in more downloads and a more powerful app store presence.
How do you resolve the "PhaseScriptExecution failed with a nonzero exit code" error when building an app on iOS 18.1 using Xcode?
That’s easy! Just follow these 7 key steps:
Step 1: Check script paths: Ensure that all script paths in your Build Phases are correct. An incorrect path can lead to this error.
Step 2: Review script permissions: Verify that the scripts have the correct execution permissions. You can adjust the permissions using the terminal command chmod +x /path/to/script.
Step 3: Environment variables: Double-check any environment variables used within your scripts. Ensure they are correctly set and accessible during the build process.
Step 4: Console logs: Examine the console logs for specific error messages. They can provide more context about what might be causing the script to fail.
Step 5: Dependencies: Ensure all dependencies and tools required by the script are installed and up-to-date. Missing dependencies can cause scripts to exit with an error.
Step 6: Xcode and SDK updates: Make sure you are using the latest version of Xcode and that your SDKs are up-to-date, as updates can sometimes resolve build-related issues.
Step 7: Rebuild clean: Try performing a clean build by selecting Product > Clean Build Folder in Xcode, then rebuild your project.
With the above steps, you should be able to identify and fix the cause of the Xcode error "PhaseScriptExecution failed with a nonzero exit code", ensuring a smooth build process for your app on iOS 18.1.
There's another way to ship on iOS
Building and maintaining a native iOS app takes more than clearing the first build error. If you're spending time debugging Xcode scripts instead of shipping features, it's worth asking whether the infrastructure layer is the right place to invest that effort.
Median.co converts existing web apps into native iOS and Android apps, handling build configuration, app store submission, and ongoing platform updates that often surface errors like this one.
Over 1.7 million apps have been built on the web-to-app platform, and Median's team handles app store submissions with a 98% approval rate.
If you're running into Xcode errors as part of a broader mobile build project, book a call with the Median team or explore the Common Xcode Issues documentation to see how our platform handles the configuration work for you.
PhaseScriptExecution error: Frequently asked questions
What does the error "PhaseScriptExecution failed with a nonzero exit code" mean?
This error typically indicates that a script phase in your Xcode build process encountered an issue and exited with a non-zero status, indicating failure. It often points to problems within the script itself or issues with the environment in which the script is running.
How can I diagnose the cause of this error?
To diagnose this error, check the build logs in Xcode for more detailed information about which script failed and why. Look for any error messages or output from the script that might give clues. Common causes include missing dependencies, incorrect script paths, or syntax errors.
What are some common solutions to fix the "PhaseScriptExecution failed with a nonzero exit code" error?
Common solutions include ensuring all script dependencies are installed and accessible, verifying the script's syntax and paths, and checking for permission issues. Sometimes, cleaning the build folder and rebuilding the project can also resolve the issue. If the script relies on environment variables, make sure they are correctly set.
How do you fix the "PhaseScriptExecution failed with a nonzero exit code" error in a Flutter project?
In Flutter projects, this error commonly arises during the Xcode build process when deploying to iOS, and is often related to shell or command scripts defined in the Xcode project settings. Start by running flutter clean followed by flutter pub get to reinstall dependencies. Then delete Podfile.lock and the Pods folder and run pod install again. Incompatible versions of Flutter or Dart can also cause command execution failures, so make sure your Flutter SDK version is compatible with your Xcode version. If the error persists, check your Build Phases for any Run Script sections that may need updating.
If you're on a newer Mac with Apple Silicon, running arch -x86_64 pod install instead of plain pod install can matter if your pods haven't been updated for arm64 yet.
How do you fix the "PhaseScriptExecution failed with a nonzero exit code" error in React Native?
React Native projects add their own build phase scripts on top of Xcode's standard process. A common cause is a missing or incorrectly pathed Node binary — you may see a message like /usr/local/bin/node: No such file or directory alongside the PhaseScriptExecution error. Run cd ios && pod install to reinstall your iOS dependencies, then clean the build folder and rebuild. If you're on Apple Silicon, check whether any native modules depend on Intel-only binaries, as migrating from an Intel machine to Apple Silicon is a known trigger for this error.
Does this error behave differently in Xcode 14, 15, or 16?
The underlying cause is the same across versions, but the error surfaces more often after upgrades because each release has tightened how scripts are handled. ENABLE_USER_SCRIPT_SANDBOXING was introduced in Xcode 14 but became the default recommended setting in Xcode 15, which is a common source of this error after upgrading. If you're hitting this after upgrading to Xcode 15 or 16, disabling User Script Sandboxing under your project's Build Settings can resolve it — or, if you'd prefer to leave sandboxing enabled, declare your script's input and output files explicitly in the Build Phase configuration.
Why does filtering to "Show all errors only" in Xcode still not explain what went wrong?
The PhaseScriptExecution error surfaces at the top level, but the actual failure is usually one level deeper. Switch from the error filter to the full build log by clicking the icon at the top right of the build results navigator, then search for the script phase name. The line just above the exit code message typically contains the specific command that failed and the reason why. Median's Common Xcode Issues guide covers additional tips for reading logs for this error.
