如何為各個 Pod 指定 Swift 版本

栏目: Swift · 发布时间: 7年前

内容简介:最近升上 Swift 4.2,發現我用到的 Pods 有些還沒支援 4.2 導致編譯錯誤。解決方法也很簡單,只要指定每個 Pod target 的但是我們不能手動在 Xcode 裡頭調整,因為 CocoaPods 會把 Pods 的我們可以在

最近升上 Swift 4.2,發現我用到的 Pods 有些還沒支援 4.2 導致編譯錯誤。解決方法也很簡單,只要指定每個 Pod target 的 SWIFT_VERSION4.0 即可。

但是我們不能手動在 Xcode 裡頭調整,因為 CocoaPods 會把 Pods 的 SWIFT_VERSION 設為跟你的 project 一樣,所以下次 pod install 又會被改掉。

我們可以在 Podfilepost_install 來自動修改,只要在 Podfile 結尾加入以下片段即可。

post_install do |installer|
  installer.pods_project.targets.each do |target|
      # 我們也可以懶惰不用 if,讓所有 pod 的版本都設為一樣的

      if ['RxSwift', 'RxSwiftExt', 'RxCocoa', 'RxDataSources', 'ProtocolBuffers-Swift'].include? target.name
          target.build_configurations.each do |config|
              config.build_settings['SWIFT_VERSION'] = '4.0'
          end
      end
  end
end

參考來源: https://stackoverflow.com/a/46690240


以上所述就是小编给大家介绍的《如何為各個 Pod 指定 Swift 版本》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Struts 2 in Action

Struts 2 in Action

Don Brown、Chad Davis、Scott Stanlick / Manning Publications / 2008.3 / $44.99

The original Struts project revolutionized Java web development and its rapid adoption resulted in the thousands of Struts-based applications deployed worldwide. Keeping pace with new ideas and trends......一起来看看 《Struts 2 in Action》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具