【问题标题】:“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift需要为使用 Swift 的目标正确配置“Swift 语言版本”(SWIFT_VERSION)
【发布时间】:2017-08-30 19:20:18
【问题描述】:

我刚刚完成了最后一次 Xcode 更新(8.3),我收到了消息:

需要为使用 Swift 的目标正确配置“Swift 语言版本”(SWIFT_VERSION)。使用 [Edit > Convert > To Current Swift Syntax...] 菜单选择 Swift 版本或使用 Build Settings 编辑器直接配置构建设置。

知道“使用旧版 Swift 语言版本”选项刚刚从构建设置中删除,我如何在 Swift 2.3 中生成我的应用程序而不进行任何转换?

【问题讨论】:

  • 你读过release notes,不是吗? – 弃用和删除通知 Xcode 8.3 不再支持 Swift 2.3。
  • 我现在明白了,使用的是 Swift 3 和 Xcode 8。嗯?

标签: ios swift xcode swift3 swift2


【解决方案1】:

在导航器选择栏中,点击放大镜,然后搜索“SWIFT_VERSION”,你会在项目中找到可以相应调整swift版本的地方。

【讨论】:

  • 这将是最好的解决方案。
【解决方案2】:

你不能。 XCode 8.2 是支持 Swift 2.3 的最后一个版本。您必须更新到 Swift 3 或使用 Xcode 8.2。

【讨论】:

【解决方案3】:

就我而言 我选择了 Pod 并更改了特定 pod 的 swift 版本。这对我有用。

【讨论】:

    【解决方案4】:

    要以编程方式更改 Swift 版本的 pod,您可以将其添加到您的 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 inference,这样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
    

    【讨论】:

      【解决方案5】:

      你不能因为 XCode 8.2 是支持 Swift 2.3 的最后一个版本。您必须将代码更新到 Swift 3 或使用 Xcode 8.2。

      【讨论】:

        【解决方案6】:

        该死的 Xcode,现在我必须迁移到 Swift 3.0。它在使用 Swift 2.3 打开或构建旧项目时清楚地显示了此警报,所以我建议让我们迁移:( :(

        【讨论】:

          【解决方案7】:

          在构建设置中将 Swift 语言版本更改为支持的版本

          【讨论】:

            【解决方案8】:

            已更新,对我有用:

            第 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 文件,清理并构建。

            【讨论】:

              猜你喜欢
              • 2017-04-30
              • 2018-03-02
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2020-05-27
              相关资源
              最近更新 更多