Xcode 10.2, Swift 5, Command compileSwift 在使用 Release Scheme 构建程序时失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/55351736/
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
Xcode 10.2, Swift 5, Command compileSwift failed while build the program with Release Scheme
提问by Ran Bi
I'm using Xcode 10.2, Swift 5.
我使用的是 Xcode 10.2,Swift 5。
With Debug scheme, no issue happens, but with Release scheme when I build or archive, it shows Command compileSwift failed with a nonzero exit code.
使用 Debug 方案,没有问题发生,但是在我构建或存档时使用 Release 方案,它显示命令 compileSwift 失败,退出代码非零。
I've tried delete DerivedData / Clean / pod deintegrate & pod install & pod update. None of these works.
我试过删除 DerivedData / Clean / pod deintegrate & pod install & pod update。这些都不起作用。
回答by Olcay Erta?
For my project problem was related to pod Cache
which gives error when Optimization Level
for Release
is set to Optimize for Speed [-O]
. I have set Compilation Mode
to Whole Module
again and set optimization level for the pod in pod file:
对于我的项目问题与 pod 有关,Cache
当Optimization Level
forRelease
设置为Optimize for Speed [-O]
. 我已Compilation Mode
到Whole Module
了在POD文件荚一次集优化级别:
post_install do |installer|
installer.pods_project.targets.each do |target|
# Cache pod does not accept optimization level '-O', causing Bus 10 error. Use '-Osize' or '-Onone'
if target.name == 'Cache'
target.build_configurations.each do |config|
level = '-Osize'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = level
puts "Set #{target.name} #{config.name} to Optimization Level #{level}"
end
end
end
end
Refrence: https://github.com/hyperoslo/Cache/issues/233#issuecomment-477749560
参考:https: //github.com/hyperoslo/Cache/issues/233#issuecomment-477749560
回答by Neil Faulkner
I fixed this issue by going Pods Projectthen to the building settings and setting Compilation Modeto Incrementalfor Release. Then clean and archive, should compile fine then.
我通过转到Pods Project然后转到构建设置并将Compilation Mode设置为Incrementalfor Release来解决此问题。然后清理并存档,然后应该可以编译正常。
回答by cgontijo
I had the same issue after upgrading to Xcode 10.2. After following the steps below it worked for me:
升级到 Xcode 10.2 后我遇到了同样的问题。按照以下步骤操作后,它对我有用:
- Update pods
- Clean project folder
- Change Pods project's Swift Language Versionto Unspecifiedand (as suggested by @Neil Faulkner) Compilation Modeto Incremental
- 更新豆荚
- 清理项目文件夹
- 将 Pods 项目的Swift 语言版本更改为未指定,并且(如@Neil Faulkner 所建议的)编译模式更改为增量
回答by An Chin
I had to set "Optimization Level" in "Swift Compiler - Code Generation" to "Release" - "No Optimization [-Onone]" from "Optimize for speed" to make Cache pass Archive.
我必须将“Swift Compiler - Code Generation”中的“Optimization Level”设置为“Release”-“优化速度”中的“No Optimization [-Onone]”,以使缓存通过存档。
Same with SwiftyBeaver
与 SwiftyBeaver 相同
It seems a problem related to Xcode 10.2. Also other pod projects seems to be fine with Optimization, like Toucan or XCGLogger.
这似乎是一个与 Xcode 10.2 相关的问题。其他 pod 项目似乎也适用于优化,例如 Toucan 或 XCGLogger。
回答by Dimillian
So I had same issue when updating my project to Swift 5. For some reason, Cocoapods (latest version, 1.6.1) set the SWIFT_VERSION of some pods to Swift 5 even if they're released as Swift 4, 4.1, 4.2 pods. So I had to add a post install script that set the correction version of swift like so
所以我在将我的项目更新到 Swift 5 时遇到了同样的问题。出于某种原因,Cocoapods(最新版本,1.6.1)将一些 Pod 的 SWIFT_VERSION 设置为 Swift 5,即使它们作为 Swift 4、4.1、4.2 Pod 发布。所以我不得不添加一个安装后脚本,像这样设置 swift 的更正版本
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'CryptoSwift' || target.name == 'SwiftyBeaver'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end
end
回答by Asadullah Ali
In my case it just appeared probably because I ran project again while it was building. So what I did was not only clean but also folder clean my project using
在我的情况下,它刚刚出现可能是因为我在构建时再次运行了项目。所以我所做的不仅是清理,而且还使用文件夹清理了我的项目
SHITF + ALT + COMMAND + K
also I deleted derived data and the project was up and running again.
我还删除了派生数据,该项目再次启动并运行。
回答by Ashish
you can follow this steps...
你可以按照这个步骤...
- Make sure to change Swift version to your current version.
- Update all your pods.
- Clean all derived data of Xcode.
- Now Restart your Mac.
- 确保将 Swift 版本更改为您当前的版本。
- 更新您的所有 Pod。
- 清除 Xcode 的所有派生数据。
- 现在重新启动您的 Mac。
You are getting all those error's just because of pods..so either you need to update every pod that you are using.
你得到所有这些错误只是因为 pods..所以你需要更新你正在使用的每个 pod。