The “Command PhaseScriptExecution failed with a nonzero exit code” error message in Xcode typically indicates an issue with an application or script execution.
Thankfully, there are steps you can take to troubleshoot and resolve this problem.
Solution #1: Refreshing Pod Dependencies
Step 1: Open the Terminal app and navigate to your Xcode project folder.
Step 2: Execute the following commands in order:
pod deintegrate
pod install
Step 3: Return to Xcode, and navigate to Product > Clean Build Folder.
Step 4: Re-run your application.
This process helps ensure that your project’s dependencies are properly configured and up to date.
Solution #2: Modifying …-frameworks.sh Files
Replace:
source=”$(readlink “${source}”)”
with
source=”$(readlink -f “${source}”)”
Solution #3: Resetting Keychain Access
- Open Keychain Access.
- Locate and select the login option, then choose Lock & Unlock Again.
- In Xcode, go to Product > Clean Build Folder.
- Retry building your application.
Resetting Keychain Access can sometimes resolve authentication-related issues that may be causing the error.
Solution #4: Checking for Special Characters in File Paths
Ensure that your project’s file paths do not contain any special characters. Spaces or other symbols may cause issues during the build process.
Solution #5: Reviewing Script Phase Outputs
- In Xcode, navigate to your project’s Build Phases.
- Review any custom scripts or build rules for potential issues. Scripts that reference missing files can trigger this error.
Solution #6: Adjusting Build Settings for ARM64 (M1 Macs)
If you are using an M1 Mac, consider adding ARM64 to the Excluded Architectures build setting for “Any iOS Simulator SDK.” This can help prevent build failures related to architecture compatibility.
If none of the above solutions work, consider reaching out to Apple Support for further assistance. They have dedicated resources to help developers resolve complex issues.
Solution-1 worked
Thanks
Glad to hear. Thanks for letting me know!
After days of having this problem, I did the following:
* Follow this StackOverflow answer https://stackoverflow.com/a/50419734/12279918
* Completely close all terminals & close XCode
* Reopen XCode to successfully start compiling & archiving iOS builds