2017-08-03 59 views
3

我正嘗試將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 

回答

3

問題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,看到更新的答案,我不確定全球目標。 –