I've developed an iOS project that is a class library dealing with different servers. Only one server is needed per application in which the library is used. The server type is configurable through a preprocessor definition at compile time.
In the podspec of my library, I defined various subspecs for each server like this:
s.name = "ServerLib"
[...]
s.subspec 'ServerA' do |a|
a.source_files = 'Classes/A/**/*.{h,m}'
a.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) ServerA=1" }
end
s.subspec 'ServerB' do |b|
b.source_files = 'Classes/B/**/*.{h,m}'
b.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) ServerB=1" }
end
My application is a multi-customer app with one target per customer. Each customer uses a specific server from the library project. So, my Podfile looks like this:
platform :ios, '5.0'
pod 'MyCore'
pod '3rdPartyLib'
target :'Customer1', :exclusive => true do
pod 'ServerLib/ServerA'
end
target :'Customer2', :exclusive => true do
pod 'ServerLib/ServerB'
end
What the pod install
script does, is merging ALL flags defined in the subspecs into one value in every pod-customerN.xcconfig file
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) 3RD_PARTY_FLAGS $(inherited) ServerA=1 $(inherited) ServerB=1
Any suggestions how to circumvent this wrong(?) behavior of Cocoapods? As far as I understand the documentation, subspec properties should inherit only from its parent specs not same-level subspecs.