Encountering the error message "PhaseScriptExecution failed with a nonzero exit code" in React Native can be frustrating, especially since it is quite generic and can be caused by a multitude of reasons. However, the most important step in resolving this issue is to gather more information about the error.
馃挕 This guide will focus solely on diagnosing the issue by obtaining more detailed error information. Understanding the ErrorThe error message "PhaseScriptExecution failed with a nonzero exit code" indicates that a script executed during the build phase of your React Native project has failed. This script could be anything from a custom build script to a CocoaPods-related script, or even a script run by React Native itself.
Accessing Detailed Error InformationThe best way to get more information about the error is by using Xcode鈥檚 built-in report nigator. Here鈥檚 how to access it:
Nigate to Reports: Go to View > Nigators > Reports. Alternatively, you can use the keyboard shortcut CMD + 9 to quickly open the Reports nigator.
Locate the Error: In the Reports nigator, find the build that failed. You can see detailed logs of the build process, including the exact script that failed and any error messages or output it produced

In Xcode you will see error "PhaseScriptExecution failed with a nonzero exit code" (in red), but above that (in blue), you will see the real error that causing the build issue.

If the Xcode nigator reports is not showing a useful error, try building the app from command line and explore the output:
xcodebuild -workspace .xcworkspace -scheme -configuration Debug -sdk iphonesimulatorJust Replace .xcworkspace with your workspace file and with your scheme.
ConclusionThe "PhaseScriptExecution failed with a nonzero exit code" error can be daunting due to its generic nature, but by accessing detailed error information through Xcode鈥檚 Reports nigator, you can pinpoint the exact cause and understand why the script is failing. This article is not about fixing the problem, but rather about gathering the necessary information to diagnose the issue. Once you he this information, you will be better equipped to address and resolve the underlying problem.