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?
In my case it was empty assets catalog, when I delete it everything was fine again.
For me the problem was that on my Podfile I didn't put
use_frameworks!
. I just uncomment that line, runpod 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
This is a known issue with Swift 4.2 and Xcode 10. I found an article here that fixed it for me: https://github.com/Yummypets/YPImagePicker/issues/236
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.
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'.
In my case, the problem was that I assigned a .swift class to the viewController in the storyboard, while the project was Objective C.
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.