【问题标题】:Use Legacy Swift Language Version” (SWIFT_VERSION) is not working使用旧版 Swift 语言版本”(SWIFT_VERSION)不起作用
【发布时间】:2016-09-19 05:28:55
【问题描述】:

我有一个 swift 版本 2.3 的应用。

当我尝试在 xcode 8 中运行并在构建设置中设置“User Legacy Swift -> YES”时,它只会给我 cocoapods 的错误。

见下图:

我的 pod 文件:

 platform :ios, '8.0'
 use_frameworks!

target 'xxx' do
pod 'Alamofire', '~> 3.3'
pod 'PKHUD', '~> 3.1'
pod 'SCLAlertView', '~> 0.5'
pod 'SwiftyJSON', '~> 2.3'
pod 'ICSPullToRefresh', '~> 0.4'
pod 'ReachabilitySwift', '~> 2.3'
pod 'IQKeyboardManagerSwift', '~> 4.0'

end

target 'xxTests' do

end

target 'xxUITests' do

end


post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '2.3'
        end
    end
    end

【问题讨论】:

标签: ios iphone swift cocoapods xcode8


【解决方案1】:

这基本上意味着 pod 是为与您当前项目不同的 swift 版本构建的。

在我的例子中,我的应用程序迁移到了 Swift 3,但我的 pod 仍然使用 Swift 2.3,因为它们还没有适应 Swift 3。您可以在这里做以下两件事中的任何一件:

  1. 转到编辑 > 转换 > 到当前 Swift 语法,将您的 pod 更改为 Swift 3(或任何最新的 Swift 版本)。
  2. 将您的主项目降级回旧版本的 Swift。

我希望这能对这个问题有所了解。

【讨论】:

    【解决方案2】:

    这是唯一对我有用的东西......

    请注意,此错误当前位于 pod 中,但可能位于项目树中的任何位置。我将向你展示如何在这个 pod 中“允许”Swift 2.3。基本上我们需要启用“Legacy Swift Language”。选择您的 pod 框架(通过在错误导航器中单击它)并在 Build Settings 下找到“Use Legacy Swift Language Version”

    将其设置为“是”。而不是再次“构建并运行”来测试它。

    查看这篇文章: http://rebeloper.com/downgrade-swift-3-swift-2-3-xcode-8/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-02
      • 1970-01-01
      • 2017-04-30
      • 1970-01-01
      • 2017-08-30
      • 2017-01-29
      • 1970-01-01
      • 2017-01-28
      相关资源
      最近更新 更多