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
30条回答
唯我独甜
2楼-- · 2020-01-24 23:31

I got this error while trying to run my unit tests in a submodule. What I have done is:

Change the simulator => Clean the project => Build the project => Run unit tests.

After this, my unit tests ran without any issue.

查看更多
倾城 Initia
3楼-- · 2020-01-24 23:31

What was causing these errors for me (I was getting 8+ for some of my cocoapods) was fixing any runtime build issues in all the pods.

查看更多
We Are One
4楼-- · 2020-01-24 23:32

I encountered this error when I was upgrading my project from Swift 4 to 5. I first updated all my pods to their latest versions. When I built, some pods showed this error.

The following steps resolved this issue for me:

  1. Removed all pods from Podfile
  2. Executed pod install to remove all installed pods
  3. Executed pod deintegrate to remove support for CocoaPods
  4. Deleted Podfile.lock and .xcworkspace from my project so no CocoaPods anymore
  5. Now my project is a pure Xcode project
  6. Opened my project from the regular .xcodeproj file
  7. Changed Swift Version of my project to Swift 5
  8. Cleaned the project (cmd+shift+K)
  9. Quitted Xcode
  10. Restored all pods to my Podfile
  11. Executed pod install to reintegrate CocoaPods and add my pods
  12. Opened the project from the .xcworkspace file
  13. Cleaned and rebuilt
  14. Some old pods that were still using Swift 4.0 (SlideMenuControllerSwift in my case) were set to Swift 5.0, caused many build errors in their code. I corrected it back to Swift 4.0 by opening the Pods project and selecting its target.
  15. Cleaned again, rebuilt.

Now I have only errors in my own project code related with difference in Swift version I made. My job now is to fix them.

查看更多
霸刀☆藐视天下
5楼-- · 2020-01-24 23:32

In my case, I was clean build folder then restart my mac then it's work.

查看更多
再贱就再见
6楼-- · 2020-01-24 23:32

I have the issue like that and my solution is change a little thing in Build Settings:

SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OPTIMIZATION_LEVEL = "-O";

it work to me

查看更多
老娘就宠你
7楼-- · 2020-01-24 23:33

In my case it was about having a file named Location. after some digging I find out that it was about having two file with the same name (weird). Cause I don't, however, it's been solved by removing the file and adding another file with a different name.

filenames are used to distinguish private declarations with the same name
查看更多
登录 后发表回答