Search
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Fixed: Error “PhaseScriptExecution failed with a nonzero exit code”

TL;DR: A quick guide that covers what the Xcode error "PhaseScriptExecution failed with a nonzero exit code" means, and the steps needed to solve it. Median's team of experts are also availble to assist in fixing this error if at-home troubleshooting doesn't work. Read more below.

What is the error “PhaseScriptExecution failed with a nonzero exit code”?

As an iOS app developer you may encounter a build-time error “PhaseScriptExecution failed with a nonzero exit code.” But what does it actually mean?

This error occurs when a build script fails to run successfully. In Xcode, various phases of the build process rely on scripts — such as those for copying resources, managing dependencies, or executing pre/post-build actions. When one of these scripts encounters an issue and does not complete properly, it returns a "nonzero exit code," indicating that it failed.

To resolve this, review the build logs to identify the specific script that caused the failure. The most common causes include missing or outdated dependencies (e.g., CocoaPods) and stale or corrupt intermediate build files.

Where does this error come from? 

This error typically arises from dependency issues within the project, such as missing dependencies, syntax errors, or outdated and incompatible pods.

So, with that in mind, how exactly can you fix this error? Let’s dive into the steps needed to resolve it.

Instant Preview

Enter any URL to build your app

Please wait ...
Oops! Something went wrong while loading...

How can I fix the error “PhaseScriptExecution failed with a nonzero exit code”?

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.

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.

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.

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.

Documentation Icon

Want to know how it all works?

Get hands-on with Median’s comprehensive documentation, and build your app with ease.

View Documentation

How can Median.co help?

Median’s team of experts have come across this error multiple times and have perfected the solution you need to fix it. 

If following the steps above does not solve the error, then our team of experts can help debug it with ease. 

If it stems from an outdated or incompatible pod, Median can provide custom development options to create an updated and functional version of your app — removing the error from the root. 

There’s more to explore in our documentation. You can also reach out to us directly! Book a call with our team of experts here.

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 cannot 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 cannot locate the automatically generated bridging header.

Here are the steps to a possible fix to this error: 

  1. Create or update the bridging header: Create a new header file and name it YourProjectName-Bridging-Header.h (if it doesn't already exist).
  2. 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).
  3. Import the Swift-generated header to your Objective-C files: #import "YourProjectName-Swift.h"
  4. Clean and build to ensure the changes take effect.

If the error persists, Median.co 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 are not Bitcode-compatible.

Here are the steps to a possible fix to this error: 

  1. Ensure your iOS Deployment Target is compatible across your project and dependenciessome text
    1. Go to Build Settings > iOS Deployment Target.
    2. Make sure the deployment target for your project is not higher than the target of your dependencies.
    3. If any dependency's target is lower, update it to match the project's deployment target.
  2. Verify Swift Version Compatibilitysome text
    1. Go to Build Settings > Swift Language Version to view the swift version.
    2. Update any dependencies to be compatible with the Swift version.
  3. Check for Bitcode compatibility, and disable Bitcode if necessary.some text
    1. 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.

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 has encountered an issue and exited with a non-zero status, which signifies 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 in the script.

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 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.

*DISCLAIMER: This content is provided solely for informational purposes. It is not exhaustive and may not be relevant for your requirements. While we have obtained and compiled this information from sources we believe to be reliable, we cannot and do not guarantee its accuracy. This content is not to be considered professional advice and does not form a professional relationship of any kind between you and GoNative.io LLC or its affiliates. Median.co is the industry-leading end-to-end solution for developing, publishing, and maintaining native mobile apps for iOS and Android powered by web content. When considering any technology vendor we recommend that you conduct detailed research and “read the fine print” before using their services.*
Back
to top