首页 文章

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

提问于
浏览
3

我的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 Files / Pods-Target1 / Pods-Target1.debug.xcconfig'或包含'Pods / Target支持构建配置中的Files / Pods-Target1 / Pods-Target1.debug.xcconfig'('MyProject / Configuration / Debug.xcconfig') .

我无法将基本配置设置为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 回答

  • 2

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

    目标1

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

    TARGET2

    #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 .

相关问题