Ivan Stojkovic
Ivan Stojkovic

Reputation: 663

CocoaPods link_with

i am trying to include different libraries for different targets.

link_with 'Target 1', 'Target 2', 'Target 3'
platform :ios, '7.0'
pod 'MMWormhole', '~> 1.1.1'

link_with 'Target 4', 'Target 5'
platform :ios, '7.0'
pod 'AFNetworking', '~> 2.5'
pod 'MBProgressHUD', '~> 0.8'
pod 'MMWormhole', '~> 1.1.1'

How to do that?

Solution (Thanks to SalvoC for solution!)

target :'Main App', :exclusive => true do
  platform :ios, '7.0'
  pod 'AFNetworking', '~> 2.5'
  pod 'MBProgressHUD', '~> 0.8'
  pod 'MMWormhole', '~> 1.1.1'

  platform :ios, '8.0'
  pod 'SplunkMint'
end

target :'Main App Extension', :exclusive => true do
  platform :ios, '7.0'
  pod 'MMWormhole', '~> 1.1.1'
end

When changing target configuration in Podfile, assure you removed all previously generated *.a files. They persist for every target and you get the error about the "duplicates" when you build.

If you changed "Other Linker Flages" manually, before running pod install, make sure you remove the old entries and put in the $(inherited).

cheers

Upvotes: 1

Views: 3297

Answers (3)

Shaked Sayag
Shaked Sayag

Reputation: 5792

As stated by Qiulang, abstract_target is now the way to link multiple pods with multiple targets:

abstract_target 'someNameForAbstractTarget' do
  pod 'podThatIsForAllTargets'
end

target 'realTarget' do
  pod 'podThatIsOnlyForThisTarget'
end

Upvotes: 0

Qiulang
Qiulang

Reputation: 12405

Cocoapods 1.0 has removed link_with & exclusive => true in favour of abstract_target.

Upvotes: 0

SalvoC
SalvoC

Reputation: 201

You shouldn't use link_with in this case. Try this:

target :'Target 1', :exclusive => true do
   platform :ios, '7.0'
   pod 'MMWormhole', '~> 1.1.1'
end

and specify the statements for each of your target

Upvotes: 5

Related Questions