xcodeproj 'Demo.xcodeproj'
platform :ios, "6.0"
target "Demo" do
pod 'Demo-A', '3.1.1'
pod 'Demo-B', '1.0'
pod 'Demo-C', '~> 1.9.0'
pod 'Demo-D', '~> 1.1'
pod 'AA', '0.0.1'
pod 'BB', '0.0.1'
pod 'CC', '0.0.1'
pod 'DD', '0.0.1'
pod 'EE', '0.0.1'
pod 'FF', '0.0.1'
pod 'GG', '0.0.1'
end
target "DemoTests" do
pod 'DemoTests-X', '3.1.1'
pod 'DemoTests-Y', '0.4.0'
pod 'DemoTests-Z', '4.1.1'
pod 'AA', '0.0.1'
pod 'BB', '0.0.1'
pod 'CC', '0.0.1'
pod 'DD', '0.0.1'
pod 'EE', '0.0.1'
pod 'FF', '0.0.1'
pod 'GG', '0.0.1'
end
target "DemoWidget" do
pod 'DemoWidget-1', '3.1.1'
pod 'DemoWidget-2', '0.4.0'
pod 'DemoWidget-3', '4.1.1'
end
this is my podfile . as u can see.
pod 'AA', '0.0.1'
pod 'BB', '0.0.1'
pod 'CC', '0.0.1'
pod 'DD', '0.0.1'
pod 'EE', '0.0.1'
pod 'FF', '0.0.1'
pod 'GG', '0.0.1'
this code is appear twice. DemoTests is test target for Demo target.while i write test file and improt the source file in Demo target.it will dependence some file in pods which in Demo target,but not in DemoTests target. so i write this Podfile code twice for dependence. but,it's ugly! my colleagues and i have to maintain two sets of such code.and my Podfile will be Bloated! i want to maintain this code once! how to do it~ I love cocoapods! i believe it will solve my problem ~ waiting for u answer~~~~
It specifies the minimum OS version you are going to support for the pod project. If your applications project's deployment target is less than the pod project mentioned iOS version, you will get a warning if there any any APIs which are deprecated in the supported OS versions in the main project.
You can use it like this to reduce your length of podfile and would also be able to maintain code once!!!
xcodeproj 'Demo.xcodeproj'
platform :ios, "6.0"
def common_pods_for_target
pod 'AA', '0.0.1'
pod 'BB', '0.0.1'
pod 'CC', '0.0.1'
pod 'DD', '0.0.1'
pod 'EE', '0.0.1'
pod 'FF', '0.0.1'
pod 'GG', '0.0.1'
end
target "Demo" do
pod 'Demo-A', '3.1.1'
pod 'Demo-B', '1.0'
pod 'Demo-C', '~> 1.9.0'
pod 'Demo-D', '~> 1.1'
common_pods_for_target
end
target "DemoTests" do
pod 'DemoTests-X', '3.1.1'
pod 'DemoTests-Y', '0.4.0'
pod 'DemoTests-Z', '4.1.1'
common_pods_for_target
end
target "DemoWidget" do
pod 'DemoWidget-1', '3.1.1'
pod 'DemoWidget-2', '0.4.0'
pod 'DemoWidget-3', '4.1.1'
end
Just define all your common pods in a variable and use it in the targets you want.
CocoaPods now recommends using an abstract_target
if you want multiple targets to share the same pods. Notice how the actual targets are nested under the new abstract one.
# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With