Build fails with “Command failed with a nonzero ex

2020-01-24 22:45发布

When I try to build my app with Xcode, an error interrupts the build process:

Command CompileStoryboard failed with a nonzero exit code

Sometimes, it shows this error instead:

Command CompileSwift failed with a nonzero exit code

I have New Build System turned on.

What can I do to fix this?

标签: xcode
2楼-- · 2020-01-24 23:09

In my case it was empty assets catalog, when I delete it everything was fine again.

Fickle 薄情
3楼-- · 2020-01-24 23:09

For me the problem was that on my Podfile I didn't put use_frameworks!. I just uncomment that line, run pod install on the terminal again. And it got fixed.

It was commented since the app was entirely made on Objective-C. Since the app now uses Swift I had to make that change on the Podfile

倾城 Initia
4楼-- · 2020-01-24 23:12

This is a known issue with Swift 4.2 and Xcode 10. I found an article here that fixed it for me:

In short, go to your projects build settings, and add a user defined setting named SWIFT_ENABLE_BATCH_MODE and set its value to NO.

Previously, I tried each of the methods suggested here (rebuild, exit Xcode, clean and rebuild, purge Derived Data files). None of them worked.

Once I added the user define build setting per the article, Swift then told me the true error. In my case, it was a missing }, but it could be any number of problems.

5楼-- · 2020-01-24 23:13

I got the same error when linking separate storyboards. The error, "Command CompileSwiftSources failed with a nonzero exit code." is shown because I simply forgot to set the view controller inside the second storyboard that I am linking as 'an initial view controller'.

6楼-- · 2020-01-24 23:15

In my case, the problem was that I assigned a .swift class to the viewController in the storyboard, while the project was Objective C.

7楼-- · 2020-01-24 23:16

When you stop building a project when the compiler is in the middle of something "important", this error could appear. In that case, building the project again and letting it finish normally makes this error disappear.

登录 后发表回答