7

Is there a way to specify in the Podfile that an xcconfig file should be #included in the the one generated by Cocoapods?

Is there an exposed method/variable for appending this #include or do I need to read the generated xcconfig and regurgitate it with the additional text?

For instance, in the generated Pods-SomeTarget.[configuration].xcconfig, I'd like to see:

#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
3
  • What #include do you want to exactly?
    – Larme
    Commented Nov 28, 2016 at 12:47
  • @Larme Added an example.
    – ray
    Commented Nov 28, 2016 at 13:38
  • 1
    You can use post_install to do that in your podfile: (a colleague did that in one of our project) 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
    – Larme
    Commented Jan 11, 2017 at 21:27

1 Answer 1

7

Include these lines in your debug and release xcconfig files, respectively:

#include "Pods/Target Support Files/Pods-Used/Pods-Used.debug.xcconfig"
#include "Pods/Target Support Files/Pods-Used/Pods-Used.release.xcconfig"

Then click on your project and in the detail navigation bar on the left switch from your current target to your project and select Info at the top. Set the project to use your base/shared config file and Debug/Release to point to your xcconfig files.

2
  • Any tips on how to make this work when there are multiple targets? Pods-Used is just one specific target. Thanks! Commented Oct 22, 2020 at 7:04
  • @DavidHodge Cocoapods should generate a separate config file for each target, in addition to each build configuration. So for two targets and two build configurations you should have 4 config files.
    – Evan R
    Commented Aug 6, 2021 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.