Podfile中的目标内的目标

问题描述:

我正尝试将Google Mobile Ads SKD安装到我的Xcode项目中。我安装的CocoaPods然后初始化一个Podfile到我的项目:Podfile中的目标内的目标

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

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

    # Pods for Cubical 

    target 'CubicalTests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

    target 'CubicalUITests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

end 

不过,我不明白为什么有我的主要项目(立方体)内的目标。我从来没有真正使用CubicalTests或CubicalUITests,因为我不需要测试我的UI或任何代码片段。 我正在考虑删除这两个文件夹。

我的问题是,

1)是否有去除从我的Xcode项目的测试和UITests文件有任何缺点?如果我这样做,我可以直接从Podfile中删除这两个目标吗?

2)假设我将保留这两个目标。我需要为所有三个目标添加吊舱吗?或者两个嵌套目标是否继承目标'Cubical'的任何Pod荚

3)我需要向链接框架添加Google Mobile Ads SDK吗?或者这已经由Cocoapods完成了?

我最终角果应该是这样的:

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

target 'Cubical' do 
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 
    use_frameworks! 
    pod 'Google-Mobile-Ads-SDK' 

    # Pods for Cubical 

    target 'CubicalTests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

    target 'CubicalUITests' do 
    inherit! :search_paths 
    # Pods for testing 
    end 

end 

问题1:

还有,当你删除TestsCubicalUITests目标&文件夹,如果你不需要任何问题执行那种测试。

问题2

你可以像下面几个目标共享豆荚,

def shared 
pod 'Google-Mobile-Ads-SDK' 
end 

target 'Target1' do 
shared 
end 

target 'Terget2' do 
shared 
end 

多个目标

#Global Pod for all targets 
pod 'Google-Mobile-Ads-SDK' 

target 'target1' do 
    pod 'Fabric' #Pod for nested Target. i.e., Google-Mobile-Ads-SDK + Fabric 
end 

target 'target2' do 
pod 'RadioButton'#Pod for nested Target. i.e., Google-Mobile-Ads-SDK + RadioButton 
end 

荚嵌套目标全球荚:

#Global Pod for all targets 
pod 'Google-Mobile-Ads-SDK' 

target 'target1' do 
    pod 'RadioButton' #Available for target1 and target2 
    target 'target2 copy' do 
     pod 'Fabric' #Available for target2 only 
    end 
end 

问题3:

链接的框架是自动的CocoaPods完成。请参阅here您需要使用没有cocoapods的框架链接框架。

+0

令人惊叹的答案,但是嵌套目标和全局目标之间有什么区别? (如果这甚至是适当的术语,而不是Ruby的经验) – Pablo

+0

@Pablo,看到更新的答案,我不确定全球目标。 –