I am trying to link a Cocoapods generated static library to multiple targets in my workspace. When I do this I get a duplicate symbols error in the linking phase when building. This makes sense as I am linking the library twice.
How do I get around this? Should I be linking to the main target only and include the headers paths to the Pods in the shared targets? How would I do this in Cocoapods? I could set the header paths to the Pods manually but seems to defeat the point of using pod install
.
Below is my workpsace setup. It consists of a main project and multiple static libraries as their own xcode projects which have shared code. I link the products of the two static library projects to the main target and they automatically become dependencies of the main target.
shared1.xcodeproj -> target shared1
shared2.xcodeproj -> target shared2
main.xcodeproj -> target main
This is my Podfile:
workspace 'Main.xcworkspace'
xcodeproj 'Main.xcodeproj'
xcodeproj 'Shared1.xcodeproj'
platform :ios
target :ThirdParty, :exclusive => true do
link_with ['main', 'shared1']
pod 'MKNetworkKit'
pod 'SBJSON'
...
end
Have you tried adding this in the podfile:
link_with 'Target1', 'Target2'
I've got 5 different targets in mine this way and it seems to work nicely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With