有没有一种方法可以在不直接更改pod项目或其他自动生成的内容的情况下在cocoapods pod中添加构建设置,以便在pod install之后仍然存在?具体地说,我需要在Mixpanel pod中设置DISABLE_MIXPANEL_AB_DESIGNER=1,以避免崩溃。
我发现了一些here,但它过时了,看起来很奇怪,因为(据我所知) podspec文件是由pod所有者创建的,而不是用户。
发布于 2017-08-15 17:39:19
谢谢,@Hodson,这就是解决方案。对documentation中的示例稍作修改,我们得到
post_install do |installer|
#Specify what and where has to be added
targetName = 'Mixpanel'
settingKey = 'DISABLE_MIXPANEL_AB_DESIGNER'
settingValue = 1
#Find the pod which should be affected
targets = installer.pods_project.targets.select { |target| target.name == targetName }
target = targets[0]
#Do the job
target.build_configurations.each do |config|
config.build_settings[settingKey] = settingValue
end
end只需将此代码添加到您的podfile即可。显然,以同样的方式,您可以对自动生成的pods项目进行任何更改,并且它们永远不会丢失。
https://stackoverflow.com/questions/45674027
复制相似问题