如何设置现有的 podfile 以兼容 CocoaPods 版本 0.39.x 和 1.0.0?

How to set existing podfile to be compatible to both CocoaPods version 0.39.x and 1.0.0?

我得到了以下与 0.39.x 兼容的 podfile。我想让它与 cocoapods 1.0.0.beta.2 兼容?我的 Podfile 如下:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '7.0'

# ignore all warnings from all pods
inhibit_all_warnings!

target 'ATests', :exclusive => true do
    pod 'AFNetworking', '~> 2.5.4'
end

link_with 'A', 'B', 'C', 'D'

pod 'WebViewJavascriptBridge', '4.1.0'
pod 'OBShapedButton', '1.0.2'
pod 'ReactiveCocoa', '2.2.4'
pod 'CocoaLumberjack', '2.0.0-beta4'
pod 'IBCustomFonts', '0.0.1'
pod 'CHDataStructures', '0.0.1'
pod 'Smooth-Line-View', :git => 'git://github.com/kccheung/Smooth-Line-View', :commit => 'c12b870f2cca75c752e0fb47d2f4d1c09ea02c94'
pod 'UIMenuItem+CXAImageSupport', :git => 'git://github.com/cxa/UIMenuItem-CXAImageSupport', :commit => 'd11a08af89b0e07ae2c1720e9c16b746dc47037d'
pod 'CrittercismSDK'
pod 'SSZipArchive'
pod 'AFDownloadRequestOperation', '2.0.1'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
pod 'RNCryptor', '~> 2.2'
pod 'AFNetworking', '~> 2.5.4'
pod 'AFNetworkActivityLogger'
pod 'nv-ios-http-status'
pod 'FLEX', '~> 2.0'

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
        end
    end
end

你应该post你所面临的问题,否则很难帮助你解决所面临的问题。

如果您不小心更新到 Cocoapods beta 并想降级,您可以使用以下命令:

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 0.39.x

As answered here,Cocoapods 1.0.0 兼容性的多种可能语法。

您可以定义通用 pods(兼容 0.39.0 和 1.0.0):

platform :ios, '7.0'

inhibit_all_warnings!

def default_pods
    pod 'WebViewJavascriptBridge', '4.1.0'
    pod 'OBShapedButton', '1.0.2'
    pod 'ReactiveCocoa', '2.2.4'
    pod 'CocoaLumberjack', '2.0.0-beta4'
    pod 'IBCustomFonts', '0.0.1'
    ...
end

target 'A' do
    default_pods
end
target 'B' do
    default_pods
end
target 'C' do
    default_pods
end
target 'D' do
    default_pods
end
target 'ATests' do
    default_pods
    pod 'AFNetworking', '~> 2.5.4'
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
        end
    end
end

或定义一个抽象目标(仅兼容 1.0.0):

platform :ios, '7.0'

inhibit_all_warnings!

abstract_target 'default_pods' do
    pod 'WebViewJavascriptBridge', '4.1.0'
    pod 'OBShapedButton', '1.0.2'
    pod 'ReactiveCocoa', '2.2.4'
    pod 'CocoaLumberjack', '2.0.0-beta4'
    pod 'IBCustomFonts', '0.0.1'
    ...

    target 'A'
    target 'B'
    target 'C'
    target 'D'
    target 'ATests' do
        inherit! :search_paths
        pod 'AFNetworking', '~> 2.5.4'
    end
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
        end
    end
end