Command PhaseScriptExecution failed with a nonzero exit code

Have you encountered this Build error in Xcode too? Here is some background and how I was able to get past this issue.

I was building just fine in the office on a Wednesday afternoon. I threw my mouse cursor into a corner and kicked off my Desktop Screensaver and left for the evening.

The next morning I came into my office and noticed my screensaver wasn’t running. I tapped the power button and the laptop booted up cold – it had crashed sometime overnight. No worries. After things settled in, I added some code to my Xcode project and built it to my phone. Build error.

Command PhaseScriptExecution failed with a nonzero exit code

What the hell is that? I have never seen that before. It’s things like this that are the worst. I figured it had something to do with the crash since I hadn’t really changed anything besides some innocuous code. I cleaned the build folder. That didn’t work. I deleted the derived data for the project. That didn’t work.

I then did what most anyone else would do… I used Google and ended up in a bunch of Stack Overflow threads, all with wild claims to fix the problem – each one with more arcane steps than the last. Not knowing the specifics of the error, I was about to go down the rabbit hole trying anything to fix the problem. Always a mistake. But most of the time Xcode build issues are above my head in regards to understanding and fixing them.

I went to an internal Slack channel and asked the question there. I figured I might get a more direct answer – and I did. Here is all I needed to do to fix the problem.

  1. Open Keychain Access
  2. Select the Apple Developer certificate & open it up
  3. Change Trust to Always (close it and enter password/finger ID)
  4. Open it up again and change it back to System Defaults. Close & save.
  5. Rebuild

That was it. I didn’t tear up my project, do anything with my Podfile, open a Terminal window and start doing scary shit I had no knowledge of the real ramifications of, etc. Hopefully if you run into this issue this point will help you solve it. Build issues and merge conflicts are the bane of our existence – am I right?

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.