swift 如何将Swift 3内置的cocoapod更新为Swift 4

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 如何将Swift 3内置的cocoapod更新为Swift 4相关的知识,希望对你有一定的参考价值。

post_install do |installer|
        myTargets = ['FolioReaderKit', 'FontBlaster', 'MenuItemKit']

        installer.pods_project.targets.each do |target|
                if myTargets.include? target.name
                        target.build_configurations.each do |config|
                                config.build_settings['SWIFT_VERSION'] = '3.2'
                        end
                end
        end
end
swift_32 = ['Pod1', 'Pod2', 'Pod3'] # if these pods are in Swift 3.2
swift4 = ['Pod4', 'Pod5', 'Pod6'] # if these pods are in Swift 4

post_install do |installer|

    installer.pods_project.targets.each do |target|
        swift_version = nil

        if swift_32.include?(target.name)
            swift_version = '3.2'
        end

        if swift4.include?(target.name)
            swift_version = '4.0'
        end

        if swift_version
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = swift_version
            end
        end

    end

end
![""](https://i.stack.imgur.com/aIT9n.png "")
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'ProjectX' do
    pod '_your_pod_'
end

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

以上是关于swift 如何将Swift 3内置的cocoapod更新为Swift 4的主要内容,如果未能解决你的问题,请参考以下文章

Swift 3:数组到字典?

将 iOS 应用程序提交到内置于 swift 1.2 中的 App Store

如何将 Swift 数组转换为字符串?

如何在swift中仅共享内置的iOS应用程序

如何以编程方式在 Swift 中将 uiimageview 设置为 xcode 内置的 applewatch 图标图像?

Swift 3替代NSStringFromCGSize