我在我继承的应用程序中收到此错误。
我不确定在不破坏应用程序的情况下应该做什么。我被告知应用程序开发的版本是Swift 3.0。我也得到了"Click update to change your target's build settings to use the latest Swift syntax"
我目前正在使用Xcode 8.2.1,项目格式与Xcode 3.2兼容。
基于我所看到的我的理解是,使用Swift 3.0版,我不需要设置它吗?设置这会做什么阻止代码编译?
我没有对Swift和Xcode的不同做很多事情,我在找到一个很好的解释我在这种情况下应该做些什么时遇到了一些麻烦。
这是一张图片:
如果你使用pod。在podfile中添加以下代码。再次安装pod有望它会工作。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
(事先注意:您可能必须在每个目标中将使用旧版swift版本设置为true,包括每个pod)
如果我是你,我会尝试使用Xcode 8.1并将使用旧版swift版本设置为true。如果它没有帮助,尝试使用最新版本,如果这不起作用,那么有可能,项目中存在非常旧的swift 2 pod或代码。
我们在Xcode 8中遇到过这个问题。我们的项目是用swift 2编写的,而Xcode 8.1是支持它的最新版本。
Xcode 9具有swift 3.2支持,实际上是swift 3,但只是为了使swift 4更容易翻译。
如果一切都失败了,请尝试使用xCode的Code Converter功能。它已成功将我们的代码库从swift 3.0转换为swift 4.0。
注意:检查每个pod及其github页面以查找哪个pod太旧,如果它是打折的库,则可能必须替换它。
类似于上面的答案,但更完整:
# swift 3 and 4 support
# define pods that use swift 4 here
swift_4 = ['Cosmos-tvOS', 'XCGLogger-tvOS', 'Cosmos-iOS', 'XCGLogger-iOS']
post_install do |installer|
installer.pods_project.targets.each do |target|
swift_version = nil
if swift_4.include?(target.name)
swift_version = '4.0'
else
swift_version = '3.2'
end
if swift_version
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = swift_version
end
end
end
end