Cocoapods 1.0:适用于多个目标的相同吊舱

时间:2016-05-19 10:13:10

标签: ios xcode cocoapods xcconfig

我的Xcode项目使用自定义.xcconfig文件进行构建设置。我有一个debug.xcconfig,beta.xcconfig和release.xcconfig。他们为相同的3个构建配置添加到每个目标:

enter image description here

我需要为所有目标集成所有pod。但是,在执行pod安装时,Cocoapods会为每个目标生成3个.xcconfig文件,并期望将这些文件添加到每个目标,或者包含在我的自定义.xcconfig文件中。消息显示:

  

CocoaPods没有设置项目的基本配置,因为   您的项目已经有自定义配置集。为了CocoaPods   集成工作,请设置基本配置   目标' Target1'到' Pods / Target Support   文件/豆荚,目标1 /豆荚-Target1.debug.xcconfig'或包括   ' Pods / Target支持文件/ Pods-Target1 / Pods-Target1.debug.xcconfig'   在您的构建配置中   (' MyProject的/配置/ Debug.xcconfig&#39)。

我无法将基本配置设置为Cocoapods生成的xcconfig文件。我需要将我的自定义xcconfig文件设置为基础,以便将我的构建设置应用于目标。所以我必须走下包含路线。 在Cocoapods 0.x中我能够将这个包含在我的自定义.xcconfig文件中:

#include "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"

但是对于Cocoapods 1.0,我预计会做这样的事情(对于我的每个xcconfigs):

#include "../Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target2/Pods-Target2.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target3/Pods-Target3.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target4/Pods-Target4.debug.xcconfig"

这不好。我的项目有12个目标,这意味着我必须在我的3个自定义.xcconfigs中分别放入12个包含,共计36个包含。必须有更好的方法。

我在我的Podfile中尝试了几种不同的方法,包括一个抽象目标,但结果总是一样的。 谁知道如何解决这个问题?

继承我的Podfile代码:

platform :ios, '8.4'
use_frameworks!


def myPods

  pod 'SplunkMint'
  pod 'Alamofire', '~> 3.0'
  pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

end

target 'target1' do
    myPods
end

target 'target2' do
    myPods
end

target 'target3' do
    myPods
end

target 'target4' do
    myPods
end

1 个答案:

答案 0 :(得分:2)

您不应在每个自定义目标配置中包含所有pod配置,但每个目标配置应仅包含它自己的参考pod配置:

Target1时

#include "../Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig"

目标2

#include "../Pods/Target Support Files/Pods-Target2/Pods-Target2.debug.xcconfig"

PodFile似乎是正确的,也许你应该在'myPods'定义之前明确目标类型:

xcodeproj 'YourProjectName', {
    'Target1' => :release,
    'Target2' => :debug,
    'Target3' => :debug
    'Target4' => :debug
}

您的xCode配置(图片)看起来也不错,与我的工作项目的唯一区别是我在项目级别选择了'none'而不是'Application'。

尝试关闭xCode,删除所有pod然后再次运行pod install。

相关问题