Since CocoaPods 1.0
改变了语法,而不是使用link_with
,做类似的事情:
# Note; name needs to be all lower-case.
def shared_pods
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
end
target 'Sail' do
shared_pods
end
target 'Sail-iOS' do
shared_pods
end
旧答案CocoaPods 1.0 之前版本:
是的,有更好的方法!查看link_with你可以在哪里做link_with 'MyApp', 'MyOtherApp'
指定多个目标。
我将其与单元测试一起使用,例如link_with 'App', 'App-Tests'
(注意目标名称中的空格)。
Example:
platform :osx, '10.8'
link_with 'Sail', 'Sail-Tests'
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
使用方法抽象目标:
在下面的示例中,'ShowsiOS'
, 'ShowsTV'
and 'ShowsTests'
目标有自己独立的 pod,另外ShowsKit
继承,因为它们都是虚拟目标的子代'Shows'
.
# Note: There are no targets called "Shows" in any of this workspace's Xcode projects.
abstract_target 'Shows' do
pod 'ShowsKit'
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
target 'ShowsTV' do
pod 'ShowTVAuth'
end
# Our tests target has its own copy
# of our testing frameworks
# (beside inheriting ShowsKit pod).
target 'ShowsTests' do
inherit! :search_paths
pod 'Specta'
pod 'Expecta'
end
end