#targetA: [AFNetworking,Masonry]#targetB:[AFNetworking,SDWebImage]
abstract_target 'abstract_pod'do#这里的abstract_pod在实际targets中不存在,是虚拟
pod 'AFNetworking'
target 'targetA'do
pod 'Masonry'end
target 'targetB'do
pod 'SDWebImage'endend
方式二:循环target 添加pod
#多个target的pod引入,方式一:如每个pod都引入masonry
targetArray =['target1','target2']
targetArray.eachdo|t|
target t do
pod 'Masonry','~> 1.1.0'endend
方式三:提取公共pods 各个target引入
#多个target的pod引入,方式二:如每个pod都引入masonrydef commonPods
pod 'Masonry','~> 1.1.0'end#工程一:
target 'AnyDoorDemo'do
commonPods
pod 'AFNetworking','~> 3.2.1'
target 'AnyDoorDemoTests'do
inherit!:search_paths
pod 'Specta','~> 1.0.7'
pod 'OCMock','~> 3.4.2'
pod 'Expecta','~> 1.0.6'end
target 'AnyDoorDemoUITests'do
inherit!:search_paths# Pods for testingendend#工程二:
target 'HostApp'do
commonPods
end
模板样例
#添加索引库索引文件地址
source 'https://github.com/LGLee/MySpaces.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios,'9.0'#多个target的pod引入def commonPods
pod 'Masonry','~> 1.1.0'end#工程一:
target 'AnyDoorDemo'do
commonPods
pod 'AFNetworking','~> 3.2.1'#测试相关↓
target 'AnyDoorDemoTests'do
inherit!:search_paths
pod 'Specta','~> 1.0.7'
pod 'OCMock','~> 3.4.2'
pod 'Expecta','~> 1.0.6'end
target 'AnyDoorDemoUITests'do
inherit!:search_paths# Pods for testingendend#工程二:
target 'HostApp'do
commonPods
end
一个工程多个target引入CocoaPods的方式方式一:循环target 添加pod#多个target的pod引入,方式一:如每个pod都引入masonrytargetArray = ['target1','target2']targetArray.each do |t| target t do pod 'Masonry', '~> 1.1.0' ...