【发布时间】:2016-11-27 22:04:48
【问题描述】:
有没有办法在 Podfile 中指定 xcconfig 文件应该是 Cocoapods 生成的文件中的 #included?
是否有用于附加此 #include 的公开方法/变量,或者我是否需要阅读生成的 xcconfig 并将其与附加文本一起反刍?
比如在生成的Pods-SomeTarget.[configuration].xcconfig中,我想看看:
#include "my_other_config.xcconfig" //<-- I want this to be inserted
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Crashlytics" "${PODS_ROOT}/Fabric" "${PODS_ROOT}/Google-Mobile-Ads-SDK/Frameworks" "${PODS_ROOT}/GoogleAds-IMA-iOS-SDK-For-AdMob/GoogleInteractiveMediaAds/GoogleInteractiveMediaAds-GoogleIMA3ForAdMob" "${PODS_ROOT}/NewRelicAgent/NewRelicAgent" "${PODS_ROOT}/TwitterCore/iOS" "${PODS_ROOT}/TwitterKit/iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
【问题讨论】:
-
你到底想要什么#include?span>
-
@Larme 添加了一个示例。
-
您可以在您的 podfile 中使用
post_install来执行此操作:(一位同事在我们的一个项目中这样做了)post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| xcconfig_path = config.base_configuration_reference.real_path puts xcconfig_path xcconfig = File.read(xcconfig_path) common_xcconfig = '#include "my_other_config.xcconfig"' File.open(xcconfig_path, "w") { |file| file << common_xcconfig file.puts file << xcconfig } end end end
标签: cocoapods xcode8 xcconfig podfile