如何在Cocoapods中为多个目标添加一个pod?

时间:2015-05-26 07:16:43

标签: ios iphone cocoapods

现在我需要将LiveSDK添加到多个目标。请参阅以下内容:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '7.0'

target :CalDoKit do
    pod 'LiveSDK'
end

pod 'Google-API-Client/Calendar'
pod 'LiveSDK'

正如您所看到的,LiveSDK pod添加了两次。当我运行应用程序时,我会从控制台输出中收到警告:One of the two will be used. Which one is undefined.

将一个pod添加到多个目标的正确方法是什么?

新代码:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '7.0'

link_with 'CalDo', 'CalDoKit'

pod 'LiveSDK'

target :CalDo do
    pod 'SVProgressHUD'
end

但我收到警告:

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `TestKit` to `Pods/Target Support Files/Pods/Pods.debug.xcconfig` or include the `Pods/Target Support Files/Pods/Pods.debug.xcconfig` in your build configuration.

2 个答案:

答案 0 :(得分:0)

  • 解决方案1:

删除'target:xx do ... end'并添加pod而不定义目标。它将为所有目标添加pod。

  • 解决方案2:

删除该podfile并从终端运行pod init命令。这将创建一个包含项目中使用的所有目标的新podfile,然后您可以为每个目标单独添加pod

答案 1 :(得分:-1)

将其添加到Podfile

target :AnotherTarget do
   pod 'LiveSDK'
end

修改

这是最终的Podfile来源

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '7.0'

target :CalDoKit do
    pod 'LiveSDK'
end

target :OtherTarget do
    pod 'LiveSDK'
end

如果在项目文件夹上执行pod init console命令,它将创建带有内置代码的Podfile

见这里:http://guides.cocoapods.org/syntax/podfile.html#target