如何在Podfile中为特定Pod设置版本?

时间:2018-10-04 11:42:43

标签: ruby xcode cocoapods podfile

这就是我在Podfile中所做的事情:

post_install do |installer|
    installer.pods_project.targets.each do |pod|
        pods = { 'CDMarkdownKit': '4.0', 'MessageKit': '4.0', 'LocalizationKit': '4.0', 'RxKeyboard': '4.0', 'JWTDecode': '3.1'}
            if pods.keys.include?(pod.name)
                pod.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = pods[pod.name]
                end
            end
        end
    end
end

但这不起作用。我不知道为什么。怎么了?

1 个答案:

答案 0 :(得分:1)

您应该对值使用符号。更新的代码如下:

post_install do |installer|
    installer.pods_project.targets.each do |pod|
        pods = {'CDMarkdownKit': '4.0', 'MessageKit': '4.0', 'LocalizationKit': '4.0', 'RxKeyboard': '4.0', 'JWTDecode': '3.1'}
        if pods.has_key?(pod.name.to_sym)
            pod.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = pods.values_at(pod.name.to_sym)
            end
        end
    end
end