ios 需要为使用 Swift 的目标正确配置“Swift 语言版本”(SWIFT_VERSION)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43226747/
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
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift
提问by ΩlostA
I just did the last Xcode update (8.3), and I have the message :
我刚刚完成了最后一次 Xcode 更新 (8.3),并且收到了以下消息:
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
需要为使用 Swift 的目标正确配置“Swift 语言版本”(SWIFT_VERSION)。使用 [Edit > Convert > To Current Swift Syntax…] 菜单选择 Swift 版本或使用 Build Settings 编辑器直接配置构建设置。
Knowing that the "Use Legacy Swift Language Version" option has just been removed from the build settings, how can I generate my app in Swift 2.3 without doing any conversion for now ?
知道“使用旧版 Swift 语言版本”选项刚刚从构建设置中删除,我现在如何在 Swift 2.3 中生成我的应用程序而不进行任何转换?
回答by ScottyBlades
回答by VojtaStavik
You can't. XCode 8.2 was the last version to support Swift 2.3. You have to either update to Swift 3 or use Xcode 8.2.
你不能。XCode 8.2 是最后一个支持 Swift 2.3 的版本。您必须更新到 Swift 3 或使用 Xcode 8.2。
回答by pallavi
回答by Ted
To programmatically change swift version of pods, you may add this inside your Podfile
要以编程方式更改 pod 的 swift 版本,您可以将其添加到 Podfile 中
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['Alamofire','OtherPod','AnotherPod'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
In Swift 4, if you are using objective-c as well,
在 Swift 4 中,如果您也使用 Objective-c,
you may turn on @objc inference so the swift project will run properly on objective-c.
您可以打开@objc 推理,以便 swift 项目将在objective-c 上正常运行。
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['Alamofire','OtherPod','AnotherPod'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_SWIFT3_OBJC_INFERENCE'] = 'On'
end
end
end
end
回答by Ankit garg
回答by Sneha
You cannot as XCode 8.2 was the last version to support Swift 2.3. You will have to either update your code to Swift 3 or use Xcode 8.2.
你不能,因为 XCode 8.2 是支持 Swift 2.3 的最后一个版本。您必须将代码更新为 Swift 3 或使用 Xcode 8.2。
回答by Satheeshwaran
回答by Kiran jadhav
Updated, It works for me:
更新,它对我有用:
Step 1:Go to your ios folder and open podfile and do below simple changes;
步骤 1:转到您的 ios 文件夹并打开 podfile 并进行以下简单更改;
first change:
第一个变化:
target 'Runner' do
use_frameworks! # <--- add this single line
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
second changes:
第二个变化:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '3.2' # <--- add this single line
end
end
end
Step 2:Open your current working project from Xcode i.e. Go to ios folder and open yourProjectName.xcworkspace file;
第 2 步:从 Xcode 打开您当前的工作项目,即转到 ios 文件夹并打开 yourProjectName.xcworkspace 文件;
Add an empty Swift file to your Flutter iOS project in Xcode and accept to add bridging header.
Step 3:Open Terminal and again install using below command;
第 3 步:打开终端并使用以下命令再次安装;
pod install
If project already open then close it and open again i.e yourProjectName.xcworkspace file , clean and build.
如果项目已经打开,则关闭它并再次打开即 yourProjectName.xcworkspace 文件,清理并构建。