美文网首页iOS集合
CocoaPods 给每个库单独指定 Swift 版本教程

CocoaPods 给每个库单独指定 Swift 版本教程

作者: Edviin_2de8 | 来源:发表于2019-02-20 15:10 被阅读0次

    苹果每年都更新 Swift 版本,但是平常项目中使用的一些开源库却不能及时更新,使用那就需要一部分库继续使用 Swift3.2 版本,一部分使用 Swift4,那么在 Podfile 中应该这么写

    platform :ios, '9.0'
    
    target 'gate' do
       use_frameworks!
       pod 'RxSwift',    '~> 4.0'
       pod 'RxCocoa',    '~> 4.0'
       pod 'WBAlamofire'
       pod 'HandyJSON'
       pod 'Kingfisher', '~> 4.8.0'
       pod 'SnapKit'
       pod 'MJRefresh', '~> 3.1.15.3'
       pod 'JPush'
       pod 'IQKeyboardManagerSwift', '~> 6.0.4'
       pod 'SDWebImage', '~> 4.0'
       pod 'CHKLineChartKit'
       
       pod 'MZFormSheetPresentationController'
       pod 'SwiftyJSON'
    
    end
    post_install do |installer|
       installer.pods_project.targets.each do |target|
           if ['CHKLineChartKit','Kingfisher','MZFormSheetPresentationController','SwiftyJSON'].include? target.name
               target.build_configurations.each do |config|
                   config.build_settings['SWIFT_VERSION'] = '4.0'
                   config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
               end
               else
               target.build_configurations.each do |config|
                   config.build_settings['SWIFT_VERSION'] = '4.2'
                   config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
               end
           end
       end
    end
    

    相关文章

      网友评论

        本文标题:CocoaPods 给每个库单独指定 Swift 版本教程

        本文链接:https://www.haomeiwen.com/subject/ucshyqtx.html