ios - 使用旧版 Swift 语言版本”(SWIFT_VERSION)不起作用

标签 ios iphone swift cocoapods xcode8

我有一个 2.3 版 swift 的应用。

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

见下图:

enter image description here

我的 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

最佳答案

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

在我的例子中,我的应用迁移到了 Swift 3,但我的 pod 仍然使用 Swift 2.3,因为它们还没有适应 Swift 3。您可以在此处执行以下两项操作之一:

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

我希望这能对这个问题有所启发。

关于ios - 使用旧版 Swift 语言版本”(SWIFT_VERSION)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39565951/

相关文章:

ios - 如何在 RxCocoa 中为自定义按钮添加控件事件?

ios - 使用 TwitterKit/Fabric 身份验证失败获取单个推文

iphone - 如何向后播放音频?

swift - 为只读计算属性赋值

ios - Swift - 延迟状态栏图标加载

ios - 解除 UIActivityViewController 后的操作

ios - 在 iOS 中创建自定义框架

iphone - UIView 的 -drawRect 是否为 : have to be called on the main thread?

iphone - 如何在不同的iPhone上检测同一用户?

swift - 如何访问 UITextView 中的各行