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

简介: 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

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

目录
相关文章
|
2月前
|
缓存 移动开发 前端开发
iOS项目组件化历程
随着业务的发展,App中的页面,网络请求,通用弹层UI,通用TableCell数量就会剧增,需求的开发人员数量也会逐渐增多。 如果所有业务都在同一个App中,并且同时开发人数较少时,抛开代码健壮性不谈,实际的开发体验可能并没有那么糟糕,毕竟作为一个开发,什么地方用什么控件,就跟在HashMap中通过Key获取Value那么简单。 那么当业务成长到需要分化到多个App的时候,组件化的重要性开始体现了。
33 0
|
2月前
|
iOS开发 Perl
将Flutter引入到现有项目中(iOS+Flutter)
将Flutter引入到现有项目中(iOS+Flutter)
|
3月前
|
JavaScript iOS开发
iOS上架之HBuider打包简单项目及注意事项
iOS上架之HBuider打包简单项目及注意事项
|
4月前
|
开发工具 iOS开发
iOS 项目无法在模拟器运行解决办法
iOS 项目无法在模拟器运行解决办法
240 0
|
4月前
|
JavaScript iOS开发
iOS上架之hubuilder打包Vue项目
1.官网下载最新的HBuilderx。 2.准备好一个包含manifest.json的Vue项目,打开进行详细设置,设置完成后,点击保存。 3.首先去App Uploader找到开发证书(开发类型是带development的),点击证书P12下载到桌面。 4.然后根据里面的Bundle ID新建一个描述文件,把描述文件也下载到桌面。 5.菜单项点击‘发行->云打包-打原生安装包’,出现如下图所示弹框,取消广告勾选项,点击打包,把前面下载好的证书,描述文件上传到原生打包列表,提交打包,等待打包完成。(仅以iOS为例) 6.打包完成后,点击“OK”保存安装包到目标文件,发送到手机端安装即可运行。
|
8月前
|
存储 编解码 编译器
iOS项目Project 和 Targets配置详解
最近开始学习完整iOS项目的开发流程和思路,在实际的项目开发过程中,我们通常需要对项目代码和资料进行版本控制和管理,一般比较常用的SVN或者Github进行代码版本控制和项目管理。
525 0
|
8月前
|
JavaScript iOS开发
ios上架之​HBuider打包简单项目及注意事项
ios上架之​HBuider打包简单项目及注意事项
ios上架之​HBuider打包简单项目及注意事项
|
9月前
|
iOS开发
iOS项目环境基本搭建
iOS项目环境基本搭建
69 0
iOS项目环境基本搭建
|
11月前
|
iOS开发 Windows
iOS开发:平时做项目经常用到的快捷键归纳
从事了这么久编程工作,总结了好多知识,但是本人之前从来没有写博客的习惯,通过去年的一次面试,明白了,不写技术博客会被面试官鄙视,所以本人痛下决心,要改变这个不爱写博客的现状,只要有时间,我就把我从开始iOS编程到现在,总结的所有内容都贴出来,之前是直接截图或者word文档,存在自己电脑里面,现在是时候把它们贴出来了。
85 0
iOS开发:平时做项目经常用到的快捷键归纳
|
11月前
|
测试技术 开发工具 Swift
iOS项目组件化
随着公司业务的不断发展,团队不断壮大的同时,项目也随之臃肿起来,如何保障团队协作的高效,自然的想到了组件化这个话题。下面总结下本人的梳理和思考。
30060 12
iOS项目组件化
相关产品
云迁移中心
推荐文章
更多