iOS cocoapods一些用法备忘

作者: shaneZhang 分类: ios技术 发布时间: 2017-03-07 21:04

一般我们在Podfile文件中指定在某个特定的scheme下引用某个框架,写法如下:


pod 'PgyUpdate', :configurations => ['Adhoc','AdhocDebug']
pod 'Reveal-iOS-SDK', '1.5.1', :configurations => ['Debug']

可以指定某个自定义框架的地址,


pod 'zucheLib_Category', :git => 'http://10.3.4.127:8888/ios_team/zuchelib_category.git', :tag => ‘0.1.2’

如果在自定义的框架下,我们使用#if DEBUG这种定义模式来区分,那么在默认Pods中是无效的。需要使用以下方法打开Debug的编译配置


post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        if target.name == 'zucheLib_Networking'
            target.build_configurations.each do |config|
                if config.name != 'Release'
                    config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'DEBUG=1']
                end
            end
        end
    end
end

如果多个target都需要引用某些公共的Pods类库框架可以使用如下写法:


def shared_pods
    platform :ios, '7.0'
    inhibit_all_warnings!  # 关闭所有警告
    #network
    pod 'AFNetworking', '~> 3.0'
end
target "XXXXXXX" do
    shared_pods
end

本页面支持繁体中文友好显示:iOS cocoapods一些用法备忘

如果觉得我的文章对您有用,请随意打赏。如果有其他问题请联系博主QQ(909491009)或者下方留言!

发表回复