Reputation: 6062
I have multiple targets in Xcode project, which must depend on the same list of pods. I could write Podfile like this:
target :target1 do
pod 'pod1'
pod 'pod2'
...
end
target :target2 do
pod 'pod1'
pod 'pod2'
...
end
but it's obviously not cool.
I wish I could write something like this:
target :target1, :target2 do
pod 'pod1'
pod 'pod2'
end
but unfortunately it doesn't work. (Note that my main target do not need these pods). Is it possible to make multiple targets to depend on same list of pods (without copy-pasting of course)?
Upvotes: 3
Views: 2309
Reputation: 1677
I have just been through this horrible situation and fixed it up - I now have a workspace that will build via command line or xcode that has 4 different targets with different bundle ID's. The problem with your approach above is that you end up with linking madness as each target will build the pods. What I did was:
My podfile looks like this - just the same as it was at the start:
target 'test-target' do
pod 'HockeySDK'
pod 'RestKit', '~> 0.23.1'
pod 'RKXMLReaderSerialization', :git => 'https://github.com/RestKit/RKXMLReaderSerialization.git', :branch => 'master'
pod 'NSLogger'
pod 'Parse-iOS-SDK'
end
I did have quite a few problems when building where it kept telling me it couldn't link to the pods build which I resolved by changing the 'Library Search Paths' in build settings to:
$(PROJECT_DIR)/Build/Products/$(CONFIGURATION)-$(PLATFORM_NAME)
It's a bit of a strange path with /Build/Products but that seems to be what Pods does out of the box and if you fight against it things get ugly.
It's hard to write a detailed how-to as it's taken me 5 days of experimentation to get the magic build working in Xcode, xcodebuild and our Teamcity CI server.
Upvotes: 1