Cocoapods 配置集锦

inhibit_warnings

inhibit_warnings参数能够有效的抑制CocoaPods引入的第三方代码库产生的warning,使用如下:

1、在 podfile 中加入 inhibit_all_warnings!

2、指定引入第三方库忽略警告:
pod 'SDWebImage', :inhibit_warnings => true

指定pod库支持的环境配置

pod 'Reveal-iOS-SDK', :configurations => ['Debug']

通过podfile设置build-setting

可以通过podfile来配置工程,如下为配置architecture:

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ARCHS'] = 'armv7 arm64'
            config.build_settings['VALID_ARCHS'] = 'armv7 arm64'
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
    end
end

undefined method `project’ for #

旧版本的Podfile在升级Cocoapods后pod install就会遇到这个问题,是因为Cocoapods升级到0.38或0.39版本后installer_representation.project.targets.each中的project改名了,变成了pods_project,如上面的配置在升级前为:

platform :ios, '7.0'
 
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ARCHS'] = 'armv7 arm64'
            config.build_settings['VALID_ARCHS'] = 'armv7 arm64'
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
    end
end

升级后是:

platform :ios, '7.0'
  
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
 
 
post_install do |installer_representation|
    
    if defined? installer_representation.project
        installer_representation.project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['ARCHS'] = 'armv7s arm64'
                config.build_settings['VALID_ARCHS'] = 'armv7s arm64'
            end
        end
    end
    
    if defined? installer_representation.pods_project
        installer_representation.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['ARCHS'] = 'armv7s arm64'
                config.build_settings['VALID_ARCHS'] = 'armv7s arm64'
            end
        end
    end
    
end

你可能感兴趣的:(Cocoapods 配置集锦)