将Cocoapods添加到多个目标

3

我需要将Alamofire添加到我的主iOS应用程序和iOS Today Extention中。只需将Alamofire放在我的iOS应用程序目标中即可正常工作!但现在,我正在尝试将Alamofire添加到我的Today Extention中。这是我的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

无论何时在终端中使用pod install,都会出现以下情况:
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.

我应该如何正确地做到这一点?

更新 - 仍然无法工作

你可能需要的一些信息是,我使用的是 cocoapods 版本 1.2.0,并且我已经尝试过 pod update,但我仍然收到那个错误。

[!] 'Pods-iFunnyVlogger' 目标有具有冲突名称的框架:alamofire。


你能告诉我你的Cocoapod版本号吗? 若要了解版本,请运行pod --version命令。 - Shah Nilay
@NilayShah 我的版本是1.2.0。 - Jacob Cavin
然后请使用“pod update”命令更新CocoaPods。然后再尝试一下,看它是否正常工作? - Shah Nilay
@NilayShah 我已经尝试过了。它会更新,然后我会收到错误提示 [!] 'Pods-iFunnyVlogger' 目标有具有冲突名称的框架:alamofire. - Jacob Cavin
@NilayShah 有什么想法吗?我一直在研究它。 - Jacob Cavin
1个回答

12

尝试这个

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

def other_pods
    pod 'Canvas'
    pod 'Firebase/Core’
    pod 'Firebase/Messagingend    

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接