美文网首页
CocoaPods: Swift语言下不更新某个库, 并指定Sw

CocoaPods: Swift语言下不更新某个库, 并指定Sw

作者: 一欧Yiou | 来源:发表于2018-09-11 10:40 被阅读3次

    指定编译版本

    指定TargetSwift 编译版本为 3.3

    post_install do |installer|
        # Your list of targets here.
        myTargets = ['Starscream']
        
        installer.pods_project.targets.each do |target|
            if myTargets.include? target.name
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '3.3'
                end
            end
        end
    end
    

    但如果是 Objective-CSwift 混编的项目, 想要引入 OC 的第三方库的话, 还需要添加另一项参数

    configuration.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO'
    

    当项目target比较多的时候应写在最外面
    举个🌰:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '9.0'
    
    def ntt_rd_pods
        # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
        use_frameworks!
        
        pod 'Starscream', '2.0.4'
    end
    
    target 'ntt-rd-showcase' do
        ntt_rd_pods
    end
    
    target 'ntt-rd-release' do
        ntt_rd_pods
    end
    
    post_install do |installer|
        # Your list of targets here.
        myTargets = ['Starscream']
        
        installer.pods_project.targets.each do |target|
            if myTargets.include? target.name
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '3.3'
                end
            end
        end
    end
    

    注: Xcode版本9.4, Swift语言4.1, 但是Starscream3.3, 所以写了这段代码, 能避免在合并代码的时候每次都要去更改Swift的语言版本, 好像还会影响lib的语言环境, 就是很麻烦, 这样写了之后省心了. 类似的库比较多的话就在 myTargets里面加就好了

        myTargets = ['Starscream', 'Starscream']
    

    相关文章

      网友评论

          本文标题:CocoaPods: Swift语言下不更新某个库, 并指定Sw

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