Jacob Cavin
Jacob Cavin

Reputation: 2319

Adding Cocoapods To Multiple Targets

I'm needing to add Alamofire to my main iOS app and the iOS Today Extention. With Alamofire just being in my iOS app target, it works great! But now, I'm trying to add Alamofire to my today extention. This is my Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'The Main iOS App' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

pod 'Canvas'
pod 'Firebase/Core’
pod 'Firebase/Messaging’
pod 'Alamofire', '~> 4.4'

  # Pods for The Main iOS App

end

target 'Today' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  pod 'Alamofire', '~> 4.4'

  # Pods for Today

end

Whenever using pod install in terminal, I get this:

Analyzing dependencies
Downloading dependencies
Using Alamofire (4.5.0)
Using Canvas (0.1.2)
Using Firebase (4.0.3)
Using FirebaseAnalytics (4.0.2)
Using FirebaseCore (4.0.3)
Using FirebaseInstanceID (2.0.0)
Using FirebaseMessaging (2.0.0)
Using GoogleToolboxForMac (2.1.1)
Using Protobuf (3.3.0)
[!] The 'Pods-iFunnyVlogger' target has frameworks with conflicting names: alamofire.

How do I properly do this?

UPDATE - Still Not Working

Some information that you may need is that I'm on cocoapods version 1.2.0 and I've tried pod update, but I'm still getting that error

[!] The 'Pods-iFunnyVlogger' target has frameworks with conflicting names: alamofire.

Upvotes: 3

Views: 4429

Answers (1)

Joe
Joe

Reputation: 4074

Try this

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

def other_pods
    pod 'Canvas'
    pod 'Firebase/Core’
    pod 'Firebase/Messaging’
end    

def shared_pods
    pod 'Alamofire', '~> 4.4'
end

target 'The Main iOS App' do
    shared_pods
    other_pods
end

target 'Today' do
    shared_pods
end

Upvotes: 12

Related Questions