ios 命令 CompileSwift 因 Xcode 10 中的非零退出代码而失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52387452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:48:16  来源:igfitidea点击:

Command CompileSwift failed with a nonzero exit code in Xcode 10

iosswiftxcodeswift4xcode10

提问by Jordi Gámez

Good afternoon,

下午好,

After updating to the latest version of Xcode at the moment (version 10.0) the project is unable to build because it found some errors regarding some "Command CompileSwift failed with a nonzero exit code" error.

目前更新到最新版本的 Xcode(版本 10.0)后,项目无法构建,因为它发现了一些关于“Command CompileSwift failed with a nonzero exit code”错误的错误。

How do I solve this errors?They appear in most of the Pods (I use CocoaPods) I use inside my project.

我该如何解决这个错误?它们出现在我在项目中使用的大多数 Pod(我使用 CocoaPods)中。

I have tried updating the pod version and the pods to the latest version available, but the problem is still there.

我已尝试将 pod 版本和 pod 更新到可用的最新版本,但问题仍然存在。

I have searched a lot through the web and there is very little information regarding this issue.

我在网上搜索了很多,关于这个问题的信息很少。

Regards.

问候。

采纳答案by Jordi Gámez

Currently my build is working. Here you are the steps I tried until it finally worked:

目前我的构建正在运行。这是我尝试过的步骤,直到它最终奏效:

  1. Search in the whole project the word CommonCrypto.
  2. If you have a Pod containing that header import, remove this Pod from the Podfile and perform a pod install.
  3. Clean and build the project.
  4. Add again the Pod to the Podfile and perform a pod install.
  5. Clean and build the project again using a real device if possible.
  1. 在整个项目中搜索单词 CommonCrypto。
  2. 如果您有一个包含该头文件导入的 Pod,请从 Podfile 中删除此 Pod 并执行 Pod 安装。
  3. 清理并构建项目。
  4. 再次将 Pod 添加到 Podfile 并执行 Pod 安装。
  5. 如果可能,使用真实设备清理并重新构建项目。

And If you don't have that Pod, maybe you can try by making the same steps with some old Pod that you may encounter in your project.

如果您没有那个 Pod,也许您可​​以尝试使用您在项目中可能遇到的一些旧 Pod 执行相同的步骤。

Added information: also If you have some code error inside a Pod, first you need to solve that code problem and then try to compile again the project.

补充说明:另外,如果你的 Pod 内部有一些代码错误,首先你需要解决那个代码问题,然后再次尝试编译项目。

I'm going to copy the changes made in my project.pbxproj. I know it's not very helpful but it's the only thing that have changed in the git difference commit:

我将复制在我的 project.pbxproj 中所做的更改。我知道这不是很有帮助,但它是 git 差异提交中唯一改变的:

Removed: BDC9821B1E9BD1B600ADE0EF /* (null) in Sources */ = {isa = PBXBuildFile; };
Added:   BDC9821B1E9BD1B600ADE0EF /* BuildFile in Sources */ = {isa = PBXBuildFile; };

I hope this can help,

我希望这可以帮助,

Regards.

问候。

回答by Mahgol Fa

For me, just cleaning project works using ShiftCommandK& OptionShiftCommandK.

对我来说,只需使用ShiftCommandK&清洁项目即可 OptionShiftCommandK

回答by Samy

You're most likely not reading the entire error message.If you look above the "Command CompileSwift failed with a nonzero exit code" message you should find some specification like this:

您很可能没有阅读整个错误消息。如果您查看“Command CompileSwift failed with a nonzero exit code”消息,您应该会发现一些这样的规范:

enter image description here

在此处输入图片说明

In this example I had two files with the same name. Once I fixed it everything worked as it should.

在这个例子中,我有两个同名的文件。一旦我修复了它,一切都会正常工作。

回答by Werner Altewischer

I had this issue and changing the Compilation Mode setting for the project from Incremental to Whole Module fixed it for me.

我遇到了这个问题,将项目的编译模式设置从增量更改为整个模块为我修复了它。

enter image description here

在此处输入图片说明

回答by codeherk

I attempted

我尝试过

  • Closing & Reopening Xcode
  • Cleaning Build Folder
  • Running pod install --repo-update
  • 关闭并重新打开 Xcode
  • 清理构建文件夹
  • 跑步 pod install --repo-update

and all of these still did not fix the problem.

所有这些仍然没有解决问题。

Restarting the Mac did the trick!

重新启动 Mac 成功了

回答by Omid Ariyan

My problem was I had due to the non-existence of a native Swift CommonCrypto, used a bridging header and a target that with some magicincluded it in the build. Since CommonCryptois now native, I solved the problem by removing the target and the #importand instead added an import CommonCryptowhere I used it.

我的问题是由于本机 Swift CommonCrypto不存在,我使用了桥接标头和一个在构建中包含一些魔法的目标。由于CommonCrypto现在是原生的,我通过删除目标和 解决了这个问题#import,而是import CommonCrypto在我使用它的地方添加了一个。

回答by cdeerinck

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

这是 Swift 4.2 和 Xcode 10 的一个已知问题。我在这里找到了一篇为我修复的文章: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.

简而言之,转到您的项目构建设置,并添加一个名为 SWIFT_ENABLE_BATCH_MODE 的用户定义设置并将其值设置为 NO。

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

以前,我尝试了其他地方建议的以下每种方法(重建、退出 Xcode、清理和重建、清除派生数据文件)。他们都没有工作。

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.

一旦我根据文章添加了用户定义构建设置,Swift 就会告诉我真正的错误。在我的情况下,它是一个缺失的},但它可能是任何数量的问题。

回答by Ankit Saini

Here is the solution: - Go to build settings - Search SWIFT_COMPILATION_MODE - If this is "Whole Module" for Release configuration then change it to "Incremental". - Archive now.

这是解决方案: - 转到构建设置 - 搜索 SWIFT_COMPILATION_MODE - 如果这是发布配置的“整个模块”,则将其更改为“增量”。- 立即存档。

When you change the setting to "Incremental" the process succeeds.

当您将设置更改为“增量”时,过程成功。

回答by ricks

Running pod install --repo-updateand closing and reopening x-code fixed this issue on all of my pods that had this error.

运行pod install --repo-update并关闭和重新打开 x-code 修复了我所有出现此错误的 pod 上的问题。

回答by Itay Bianco

in my case the problem was due to watchkit extension being set to swift 3 while the main project's target was set to swift 4.2

在我的情况下,问题是由于 watchkit 扩展设置为 swift 3 而主项目的目标设置为 swift 4.2