iOS开发 -多Target项目如何优雅的使用pods

多target项目适合需要经常打不通环境包的人,方便管理不同环境的项目,具体做法可以查看一个工程多环境切换,适合需要经常打很多不同环境包的人。

多target的时候,如何使用pod呢?正常情况,你的pod是这样的:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'platform :ios, '8.0'
inhibit_all_warnings!target 'TestDemo' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemopod 'UMessage'pod 'MJRefresh'
endtarget 'TestDemoBeta' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoBetapod 'UMessage'pod 'MJRefresh'
endtarget 'TestDemoTest' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoTestpod 'UMessage'pod 'MJRefresh'
endtarget TestDemoPlatform' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoPlatformpod 'UMessage'pod 'MJRefresh'
end

如果使用的第三方比较少,你且可以这么写,但是如果比较多怎么办?这里博主给出一个优雅的写法:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'platform :ios, '8.0'
inhibit_all_warnings!def testDemo_podspod 'UMessage'pod 'MJRefresh'
end
target 'TestDemo' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemo
testDemo_pods
endtarget 'TestDemoBeta' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoBeta
testDemo_pods
endtarget 'TestDemoTest' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoTest
testDemo_pods
endtarget TestDemoPlatform' do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# use_frameworks!# Pods for TestDemoPlatform
testDemo_pods
end

也就是只需要增加一个定义:

//这里注意,testDemo_pods这个定义的名字一定不能大写字母开头,否则pod install不执行,小写即可
def testDemo_pods
end

你学会了么?喜欢就点个赞吧。


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部