简体   繁体   English

Xcode 10 构建失败,“命令 CompileSwift 失败,退出代码为非零”

[英]Xcode 10 build fails with 'Command CompileSwift failed with a nonzero exit code

I updated Xcode to version 10 recently and started to receive a strange error when trying to build my project.我最近将 Xcode 更新到版本 10,并在尝试构建我的项目时开始收到一个奇怪的错误。 I'm currently on Swift 4.0 and I did try to upgrade to swift Version 4.2.我目前在 Swift 4.0 上,我确实尝试升级到 swift 版本 4.2。 But when I did I received this same error in many of my frameworks.但是当我这样做时,我在许多框架中都收到了同样的错误。

Command Compile Swift failed with a nonzero exit code命令编译 Swift 失败,退出代码为非零

So far I've deleted the derived folder.到目前为止,我已经删除了派生文件夹。 Updated all pods, also deleted all pods and reinstalled them using the terminal commands below.更新了所有 pod,还删除了所有 pod,并使用下面的终端命令重新安装了它们。

sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
pod install

This didn't work to fix my issue.这无法解决我的问题。 However, I found something that could work which was adding arm64 architecture in Build Setting -> valid architectures and enabling automatic code But, when I checked it was already there and code signing was enabled already.但是,我发现一些可行的方法是在Build Setting -> valid architectures中添加arm64架构并启用自动代码但是,当我检查它已经存在并且代码签名已经启用时。

Additionally, I do have a few other build errors that have to do with frameworks.此外,我确实有一些与框架有关的其他构建错误。

SwiftMessages SwiftMessages

Value of type 'SwiftMessages.Config' has no member 'presentationContext' “SwiftMessages.Config”类型的值没有成员“presentationContext”

WhatsNewKit WhatsNewKit

Missing argument for parameter 'backgroundColor' in call`调用中缺少参数“背景颜色”的参数

I opened issues with the developers of each of these frameworks to seek help with these issues.我向每个框架的开发人员提出了问题,以寻求解决这些问题的帮助。

Issue On SwiftMessage GitHub Issue On WhatsNewKit GitHub SwiftMessage 上的问题 GitHub WhatsNewKit 上的问题 GitHub

When I click presentationContext it brings me to the struct within the SwiftMessages Framework.当我单击presentationContext时,它会将我带到SwiftMessages框架中的结构。 Usually, when I've had the "has no member" warning I cannot click to see the original place where it exists.通常,当我收到“没有成员”警告时,我无法点击查看它存在的原始位置。

I assume this has something to do with cocoa pods, but haven't been able to find a solution yet.我认为这与 cocoa 吊舱有关,但还没有找到解决方案。 What can I do to correct this issue?我能做些什么来纠正这个问题? If anyone could help would be deeply appreciated been stuck on this for a day now.如果有人可以提供帮助,我们将不胜感激,现在已经坚持了一天。

Update: The two frameworks latest builds were for swift 4.2.更新:最新构建的两个框架适用于 swift 4.2。 When I changed the version of each framework to one that was built in swift 4.0 I got the project to build.当我将每个框架的版本更改为在 swift 4.0 中构建的版本时,我得到了要构建的项目。

Make sure that, your project Swift Language Version is in the proper version.确保您的项目 Swift 语言版本是正确的版本。 SwiftMessages 6.0.0 works with Swift 4.2. SwiftMessages 6.0.0 适用于 Swift 4.2。 Xcode->Project->Target->Build Settings->Swift 语言版本

Make sure that, Your project build settings Optimization Level is in No Optimization[-Onone].确保您的项目构建设置优化级别处于无优化 [-Onone]。

在此处输入图片说明

Set Swift version to 4.2 then pod deintegrate, pod install, fix this problem for me.将 Swift 版本设置为 4.2,然后 pod deintegrate,pod install,为我解决这个问题。 Thanks @alejandro-iván谢谢@alejandro-iván

I solved this way:我是这样解决的:

  1. Comment all pods in your .pod file注释.pod文件中的所有 pod
  2. From your terminal, run the command pod install --no-repo-update从终端运行命令pod install --no-repo-update
  3. Open Xcode perform a clean and rebuild the project打开Xcode执行清理并重建项目
  4. Now open your .pod file and uncomment the first library现在打开您的.pod文件并取消注释第一个库
  5. From your terminal, run the command pod install从终端运行命令pod install

Repeat steps 2 - 3 - 4 -5 for each uncomment library in your .pod file.pod文件中的每个取消注释库重复步骤2 - 3 - 4 -5

I hope it can be of your help.我希望它能对你有所帮助。

for pod SwiftMessages if your app is not swift 4.2 you need to user the version 5.01 pod 'SwiftMessages', '~> 5.0.1'对于 pod SwiftMessages,如果您的应用不是 swift 4.2,您需要使用 5.01 版的 pod 'SwiftMessages', '~> 5.0.1'

and it will work like a charm它会像魅力一样发挥作用

在此处输入图片说明

This error happened to me when I used same class name in two different groups.当我在两个不同的组中使用相同的类名时,这个错误发生在我身上。 Then I renamed one of the classes and the problem was solved然后我重命名了其中一个类,问题就解决了

I had several frameworks (homegrown) plus my app.我有几个框架(本土)加上我的应用程序。 Somehow they ended up being out of sync as far as the Swift version.不知何故,他们最终与 Swift 版本不同步。 Make sure that all frameworks are the same version.确保所有框架都是相同的版本。 In my case, they all needed to be set to Swift 4.2.就我而言,它们都需要设置为 Swift 4.2。 If you haven't done the migration to 4.2 then remember that Xcode helps with this: Edit -> Convert -> To Current Swift Syntax.如果您还没有迁移到 4.2,请记住 Xcode 对此有帮助:Edit -> Convert -> To Current Swift Syntax。

All of the answers were helpful to me.所有的答案对我都有帮助。 In my case, I only install frameworks manually but this kind of problem also happens.就我而言,我只手动安装框架,但也会发生这种问题。 I tried all of the answers and was still getting this issue during the build.我尝试了所有答案,但在构建过程中仍然遇到此问题。 Curiously, while coding, I could cmd-click and resolve all of the "missing" components.奇怪的是,在编码时,我可以 cmd-click 并解决所有“丢失”的组件。 I also cleaned and deleted derived data, restarted Xcode, etc.我还清理和删除了派生数据,重新启动了 Xcode 等。

I eventually got it working by inducing these additional steps:我最终通过引入这些额外的步骤让它工作:

On each of the framework project/targets (including my own):每个框架项目/目标(包括我自己的)上:

  • Verify consistent Swift version (4.2 in my case)验证一致的 Swift 版本(在我的情况下为 4.2)
  • Set Build for Active Architecture Only to No将仅针对活动架构的构建设置为
  • Set Valid Architecture to arm64, armv7 (to match with base project)将 Valid Architecture 设置为arm64、armv7 (与基础项目匹配)
  • Set Optimization Level to None (for Debug)将优化级别设置为(用于调试)
  • Set Compilation Mode to Whole将编译模式设置为整体

Good Morning!早上好! Do a clean.干干净净。 using" commond + shift + k Close Xcode. Navigate to project directory where the Podfile exist. Do pod update/pod install Open x.xcworkspace使用" commond + shift + k关闭Xcode。导航到Podfile 所在的项目目录。执行pod update/pod install 打开x.xcworkspace

I stumbled upon this problem when upgrading to Xcode 10.2 and Swift 5. After trying everything I found this in the release notes:我在升级到 Xcode 10.2 和 Swift 5 时偶然发现了这个问题。 在尝试了所有内容后,我在发行说明中发现了这个问题:

The Swift compiler may crash during a build when the Thread Sanitizer is enabled.启用 Thread Sanitizer 时,Swift 编译器可能会在构建期间崩溃。 (48719789) (48719789)

And sure enough, efter turning off Thread Sanitizer my project could be compiled without errors again.果然,关闭 Thread Sanitizer 后,我的项目可以再次编译而不会出错。

So if you get this error and have Thread Sanitizer enabled - turn it off!因此,如果您收到此错误并启用了 Thread Sanitizer - 将其关闭!

Same issue happened to me in Xcode 10.2, it was a Xcode bug..!同样的问题在 Xcode 10.2 中发生在我身上,这是一个 Xcode 错误..! So, I opened in older Xcode version(9.4), and it worked fine.所以,我在旧的 Xcode 版本(9.4)中打开,它运行良好。 Then I updated to the Xcode 10.2.1 after it's release -> Clean and build your project, now my problem solved.然后我在发布后更新到 Xcode 10.2.1 -> Clean and build your project,现在我的问题解决了。

I'm having the same problem, my Xcode version is 10.2.1 (10E1001), Cocoapods version is 1.7.0.beta.2.我遇到了同样的问题,我的 Xcode 版本是 10.2.1 (10E1001),Cocoapods 版本是 1.7.0.beta.2。

I returned to Cocoapods 1.6.1 and the problem was solved.回到Cocoapods 1.6.1,问题解决了。 The specific steps are:具体步骤是:

  1. pod deintegrate to cancel the integration. pod deintegrate取消集成。
  2. Uninstall all Cocoapods.卸载所有 Cocoapods。

     for i in $( gem list --local --no-version | grep cocoapods ); do gem uninstall $i; done
  3. Install the stable version of Cocoapods.安装稳定版的 Cocoapods。 For now it's 1.6.1.现在是 1.6.1。

     gem install cocoapods
  4. Clean Project and empty DerivedData⁩清理项目并清空派生数据

  5. pod install
  6. Recompile the project重新编译项目

In my case it was a code error:就我而言,这是一个代码错误:

self.myDto.map{ (dto)} in 
      var stringValue = (dto.value(forKey: "name") as! String)
      stringValue.append("c")
      return stringValue
}

Just removed that stringValue variable fixed the problem.刚刚删除那个stringValue变量解决了这个问题。

I just had the same error message and none of the answers here and in the duplicates of this question were applicable to my project or helpful.我只是有相同的错误消息,这里和这个问题的副本中的任何答案都不适用于我的项目或有帮助。 I kept on reading through the error messages and came to a realisation that I had stupidly named two seperate swift files in different folders with the same name intending to change one, but before I got to change one, I tried to run my project and have been annoyed for the last hour.我继续阅读错误消息并意识到我愚蠢地将两个单独的 swift 文件命名为不同文件夹中的同名文件,打算更改一个,但在更改一个之前,我尝试运行我的项目并生气了最后一个小时。

Bottom line, don't accidentally name your files the same name and read your error codes thoroughly!最重要的是,不要意外地将您的文件命名为相同的名称并彻底阅读您的错误代码!

only for re-install pod using that command pod install see below attachment仅用于使用该命令重新安装pod pod install请参阅下面的附件

https://i.stack.imgur.com/dbGyV.png https://i.stack.imgur.com/dbGyV.png

In my case I connect an actual iphone not simulator and run the app once on it, It solved the problem.在我的情况下,我连接了一个实际的 iphone 而不是模拟器,并在上面运行了一次应用程序,它解决了这个问题。 But connect iphone firstly, then choose it from this menu, then press run button.但是先连接iphone,然后从这个菜单中选择它,然后按运行按钮。 The problem will solve too.问题也会解决。

在此处输入图片说明


target 'XYZ' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for xyz
  pod 'SwiftyJSON'
  pod 'Localize-Swift'
    pod 'Alamofire'
    pod 'Kingfisher'
    pod 'Tabman'
    pod 'RSSelectionMenu'
    pod 'Pushbots'
    pod 'ACProgressHUD-Swift', '~> 1.4' 
    pod 'SKPhotoBrowser'
    pod 'ZoomableImageSlider'
    pod 'RSSelectionMenu'
    pod 'DropDown'
    pod 'ImagePicker'

end

I updated platform :ios, '10.0' to 11.0 and the error disappeared.我将平台 :ios, '10.0' 更新为 11.0,错误消失了。 Change your platform or OS version and check.更改您的平台或操作系统版本并检查。 Hope that could help.希望能有所帮助。

指定您的 pod 版本,例如pod 'RealmSwift', '~> 5.3.5'或取消注释# platform :ios, '9.0'在您的 Podfile 中

I faced this issue on Xcode 14. Add this on podfile bottom.我在 Xcode 14 上遇到了这个问题。在 podfile 底部添加这个。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
    # some older pods don't support some architectures, anything over iOS 11 resolves that
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xcode 11.0 beta 中的“Command CompileSwift 失败,退出代码非零” - "Command CompileSwift failed with a nonzero exit code" in Xcode 11.0 beta Xcode 13.3 构建失败:命令 EmitSwiftModule 失败,退出代码非零 - Xcode 13.3 build fails: Command EmitSwiftModule failed with a nonzero exit code 使用 Xcode 12.5 构建失败,CompileSwift 失败并出现非零退出代码和分段错误:11 - Building with Xcode 12.5 fails with CompileSwift failed with a nonzero exit code and Segmentation fault: 11 我有一个错误“Command CompileSwift failed with a nonzero exit code” - I have an error " Command CompileSwift failed with a nonzero exit code" NativeScript iOS 构建失败 Xcode - 错误:命令 Ld 失败,退出代码非零 - NativeScript iOS Build Fails Xcode - Error: Command Ld failed with a nonzero exit code Xcode 10 Alamofire 命令 PhaseScriptExecution 失败,退出代码非零 - Xcode 10 Alamofire Command PhaseScriptExecution failed with a nonzero exit code Xcode 10,命令 CodeSign 失败,退出代码非零 - Xcode 10, Command CodeSign failed with a nonzero exit code Xcode 11.6 失败:命令 PhaseScriptExecution 失败,退出代码为非零 - Xcode 11.6 fails with: Command PhaseScriptExecution failed with a nonzero exit code "构建失败并显示“命令 PrecompileSwiftBridgingHeader 失败,退出代码为非零”" - Build fails with "Command PrecompileSwiftBridgingHeader failed with a nonzero exit code" xcode 命令 PhaseScriptExecution 失败,退出代码为非零 - xcode Command PhaseScriptExecution failed with a nonzero exit code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM