Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapods: Linking pod to multiple targets issue

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
like image 943
Fergal Rooney Avatar asked Jun 21 '13 19:06

Fergal Rooney


1 Answers

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.

like image 63
Mike Avatar answered Sep 18 '22 15:09

Mike