![](/img/trans.png)
[英]Cocoapods post_install, how to add target membership in Pods project
[英]Get cocoapods version in post_install
是否可以在Podfile的post_install中知道安装了哪个版本的cocoapods? 如果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
我找到了一种方法,也许这不是最好的解决方案,但它可行:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.