Resolving “Command PhaseScriptExecution failed with a nonzero exit code” Error in Xcode

Tuğberk Can Özen
2 min readJun 7, 2023
Error

Introduction

As a iOS developer, I’ve encountered and overcome numerous challenges throughout my career. However, each new project tends to present a unique set of issues to tackle. Recently, while working on a sophisticated app, I faced the “Command PhaseScriptExecution failed with a nonzero exit code” error. This arose after incorporating SwiftLint into my Xcode project, a best-practice I regularly adopt to maintain high code quality.

The Problem Emerges

The error message indicated a problem during the build phase of the application. It became evident that the SwiftLint script, integral to the build process, was failing, causing the entire build to fail and display the “nonzero exit code” message.

Deciphering the Issue

Having dealt with a wide range of issues in the past, I was aware that this error typically surfaces when a script run during the build process encounters a problem and terminates with a non-zero exit status. The exit status is a numerical value that a completed process returns to the system. In this context, zero denotes successful execution, whereas any non-zero value flags an error.

Delving into the Solution

--

--

Tuğberk Can Özen
Tuğberk Can Özen

Written by Tuğberk Can Özen

iOS Developer👨🏻‍💻 at @Loodos | Founder at @SwiftAkademi | UIKit • SwiftUI