是否可以在Podfile的post_install中知道安装了哪个版本的cocoapod?如果cocoapods版本为1.5
,我想添加两个配置设置post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name === 'AlamofireImage'
config.build_settings['SWIFT_VERSION'] = '3.3'
end
config.build_settings['CONFIGURATION_BUILD_DIR'] = '$PODS_CONFIGURATION_BUILD_DIR'
# if cocoapods version == 1.5
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
end
答案 0 :(得分:0)
我找到了一种方法,也许这不是最好的解决方案,但它可行:
pod_version = `pod --version` # using backticks you can execute shell commands and get result
pod_version ["\n"] = "" # here remove the trailing \n
if pod_version === '1.5.0'
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end