Build fails with "Command failed with a nonzero exit code"

Solution 1:

Closing Xcode for me didn't have an effect. Instead, I cleaned the project using CommandShiftK.


I also found another reason: I had a storyboard reference to another storyboard which I had removed. The quick fix was deleting this.

enter image description here

Solution 2:

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.

Solution 3:

I also facing same issue in xcode 10 and tried all the solutions provided but nothing working.

Then I deleted all the files and folders of the following folder :

~/Library/Developer/Xcode/DerivedData

and it worked like a charm.

Solution 4:

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.

Solution 5:

This error happened to me when I forgot to change entity Properties before creating NSManagedObject subclass. Solved by:

  1. delete Entity+CoreDataClass.swift and Entity+CoreDataProperties.swift.
  2. under "class" of the entity model inspector, change "module" to Current Product Module and "codegen" to Manual/None.
  3. recreate the NSManagedObject.

image