需要为使用 Swift 的目标正确配置“Swift 语言版本”(SWIFT_VERSION)
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift
我刚刚完成了最后一个 Xcode 更新 (8.3),我收到消息:
“Swift 语言版本”(SWIFT_VERSION) 需要为使用 Swift 的目标正确配置。使用 [Edit > Convert > To Current Swift Syntax...] 菜单选择 Swift 版本或使用 Build Settings 编辑器直接配置构建设置。
知道 "Use Legacy Swift Language Version" 选项刚刚从构建设置中删除,我现在如何在不进行任何转换的情况下在 Swift 2.3 中生成我的应用程序?
你不能。 XCode 8.2 是最后一个支持 Swift 2.3 的版本。您必须更新到 Swift 3 或使用 Xcode 8.2.
你不能,因为 XCode 8.2 是支持 Swift 2.3 的最后一个版本。您必须将代码更新为 Swift 3 或使用 Xcode 8.2.
该死的 Xcode,现在我必须迁移到 Swift 3.0。它清楚地显示了关于使用 Swift 2.3 打开或构建旧项目的警报,所以我建议让我们迁移 :( :(
在导航器选择栏中,单击放大镜,然后搜索“SWIFT_VERSION
”,您将在项目中找到可以相应调整 swift 版本的位置。
在构建设置中将 Swift 语言版本更改为受支持的版本
以我为例
我选择了 Pod 并更改了特定 Pod 的 swift 版本。这对我有用。
要以编程方式更改 pods 的 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
在 Swift 4 中,如果您也使用 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
Updated, It works for me:
第 1 步:
转到您的 ios 文件夹并打开 podfile 并进行以下简单更改;
第一个变化:
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')
秒变:
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
第 2 步:
从 Xcode 打开您当前的工作项目,即转到 ios 文件夹并打开 yourProjectName.xcworkspace 文件;
Add an empty Swift file to your Flutter iOS project in Xcode and accept to add bridging header.
第 3 步:
打开终端并使用以下命令再次安装;
pod install
如果项目已经打开,则关闭它并再次打开即 yourProjectName.xcworkspace 文件,清理并构建。
我刚刚完成了最后一个 Xcode 更新 (8.3),我收到消息:
“Swift 语言版本”(SWIFT_VERSION) 需要为使用 Swift 的目标正确配置。使用 [Edit > Convert > To Current Swift Syntax...] 菜单选择 Swift 版本或使用 Build Settings 编辑器直接配置构建设置。
知道 "Use Legacy Swift Language Version" 选项刚刚从构建设置中删除,我现在如何在不进行任何转换的情况下在 Swift 2.3 中生成我的应用程序?
你不能。 XCode 8.2 是最后一个支持 Swift 2.3 的版本。您必须更新到 Swift 3 或使用 Xcode 8.2.
你不能,因为 XCode 8.2 是支持 Swift 2.3 的最后一个版本。您必须将代码更新为 Swift 3 或使用 Xcode 8.2.
该死的 Xcode,现在我必须迁移到 Swift 3.0。它清楚地显示了关于使用 Swift 2.3 打开或构建旧项目的警报,所以我建议让我们迁移 :( :(
在导航器选择栏中,单击放大镜,然后搜索“SWIFT_VERSION
”,您将在项目中找到可以相应调整 swift 版本的位置。
在构建设置中将 Swift 语言版本更改为受支持的版本
以我为例 我选择了 Pod 并更改了特定 Pod 的 swift 版本。这对我有用。
要以编程方式更改 pods 的 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
在 Swift 4 中,如果您也使用 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
Updated, It works for me:
第 1 步: 转到您的 ios 文件夹并打开 podfile 并进行以下简单更改;
第一个变化:
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')
秒变:
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
第 2 步: 从 Xcode 打开您当前的工作项目,即转到 ios 文件夹并打开 yourProjectName.xcworkspace 文件;
Add an empty Swift file to your Flutter iOS project in Xcode and accept to add bridging header.
第 3 步: 打开终端并使用以下命令再次安装;
pod install
如果项目已经打开,则关闭它并再次打开即 yourProjectName.xcworkspace 文件,清理并构建。