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 TestDemo
pod 'UMessage'
pod 'MJRefresh'
end
target 'TestDemoBeta' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for TestDemoBeta
pod 'UMessage'
pod 'MJRefresh'
end
target 'TestDemoTest' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for TestDemoTest
pod 'UMessage'
pod 'MJRefresh'
end
target TestDemoPlatform' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for TestDemoPlatform
pod '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_pods
pod '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
end
target '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
end
target '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
end
target 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

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

为TA充电
共{{data.count}}人
人已赞赏
iOS文章

iOS开发product文件夹下有两个相同的.app文件怎么办,该怎么删除

2021-2-2 4:22:26

iOS文章

iOS开发聊天气泡的绘制和聊天消息列表

2021-2-2 5:15:25

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索