3

My Xcode project uses custom .xcconfig files for build settings. I have a debug.xcconfig, beta.xcconfig and release.xcconfig. They're added to each target for the same 3 build configurations:

enter image description here

I need all my pods integrated for all targets. However, when doing a pod install, Cocoapods generates 3 .xcconfig files for each target and expects those to be added to each target, or included in my custom .xcconfig file. The message reads:

CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target 'Target1' to 'Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig' or include the 'Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig' in your build configuration ('MyProject/Configuration/Debug.xcconfig').

I can't set the base configuration to the Cocoapods generated xcconfig file. I need my custom xcconfig file to be set as the base, as to apply my build settings to the target. So I'll have to go down the include route. In Cocoapods 0.x I was able to just put this include in my custom .xcconfig files:

#include "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"

But with Cocoapods 1.0, I'm expected to do something like this (for each of my xcconfigs):

#include "../Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target2/Pods-Target2.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target3/Pods-Target3.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target4/Pods-Target4.debug.xcconfig"

This is not good. My project has 12 targets, which means I have to put 12 includes in each of my 3 custom .xcconfigs, totalling 36 includes. There must be a better way.

I've tried several different approaches in my Podfile, including an abstract target, but the result is always the same. Anyone knows how to solve this?

Heres my Podfile code:

platform :ios, '8.4'
use_frameworks!


def myPods

  pod 'SplunkMint'
  pod 'Alamofire', '~> 3.0'
  pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

end

target 'target1' do
    myPods
end

target 'target2' do
    myPods
end

target 'target3' do
    myPods
end

target 'target4' do
    myPods
end
Telstar
  • 143
  • 8
  • Can you post your podFile code? – lubilis May 19 '16 at 10:32
  • This is my current Podfile. But as I mentioned, i've tested different version, all with the same outcome. platform :ios, '8.4' use_frameworks! def myPods pod 'SplunkMint' pod 'Alamofire', '~> 3.0' pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git' end target 'target1' do myPods end target 'target2' do myPods end target 'target3' do myPods end target 'target4' do myPods end – Telstar May 19 '16 at 10:50

1 Answers1

3

You shouldn't include all the pod config in every custom target config. Each target config should include only it's own reference pod config:

Target1

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

Target2

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

Your PodFile seems correct, you could also add the explicit target type before 'myPods' definition

xcodeproj 'YourProjectName', {
    'Target1' => :release,
    'Target2' => :debug,
    'Target3' => :debug
    'Target4' => :debug
}

Your xCode configurations (the image) seems correct too, the only difference with my working project is that I have selected 'none' instead of 'Application' at project level.

Try to close xCode, remove all the pods and then run again pod install

lubilis
  • 3,942
  • 4
  • 31
  • 54
  • Let me see if I understand you correctly: Debug configuration: for target1 I set the base configuration file to target1-debug.xcconfig (which would be a new file I create). In this file, I include its own reference pod config, as well as my existing Debug.xcconfig. Same procedure for remaining targets. Cocoapods 0.x: I could get by with my Debug.xcconfig as base conf file for all targets (in Debug configuration). Cocoapods 1.0: each target needs to have it's own base conf file, which in turn includes whatever I need (as mentioned above). Correct? – Telstar May 19 '16 at 11:45
  • Sounds good, i have a project configured as this with Cocoapods 1.0 and works well – lubilis May 19 '16 at 12:31
  • 1
    Thanks a lot. Took a little effort but is now working. – Telstar May 19 '16 at 13:30