
选Github或者码云都可以,本例以Github为例。创建私有索引库用来作为自己组件库的索引:
@H_404_15@二、本地添加私有索引库添加:pod repo add 索引库名称 索引库地址
例:pod repo add ZYHModule https://github.com/zyhDeveloper/ZYHModule.git
查询:pod repo
三、创建组件库(同步骤一 *** 作,在Github或者码云上创建) 四、创建组件工程 1、快速创建模版库在命令行工具里cd进入桌面文件夹
执行:pod lib create 组件名
例:pod lib create XXModules
2、添加组件内容我们把基础组件相关的东西丢到Classes文件夹中,并且把ReplaceMe.m文件删除
执行:
git rm XXModule/Classes/ReplaceMe.m
git add .
git commit -m ‘firstCommit‘ 3、安装与测试本地库在Example项目的Podfile文件中可以看到 “ pod ‘LXFBase‘,:path => ‘../‘ ”,模板库已经默认帮我们在Podfile中指定了LXFBase.podspec的位置,我们无需 *** 作,直接在命令行工具里cd到Example文件夹,执行pod install
4、 修改Spec 四、上传组件代码 1、将代码提交到组件仓库 git add . git commit -m ‘firstCommit‘ git remote add origin https://gitee.com/LinXunFeng/LXFBase.git git push -f origin master 2、打标签
标签与spec中的s.version保持一致
git tag -a 0.1.0 -m "Release version 0.1.0"
git push origin --Tags
五、提交podspec到私有索引库先做个本地和远程验证
1、本地验证pod lib lint --allow-warnings
2、远程验证 pod spec lint --allow-warnings 3、提交podspec 执行: pod repo push 私有索引库名称 spec名称.podspec pod repo push ZYHModule XXModule.podspec --allow-warnings 六、使用私有库测试下搜索我们的组件:pod search XXModules
1、添加Podfile文件cd到开发的项目工程文件
执行:pod init
2、在Podfile的最顶部添加如下描述// 第二行是为了保证公有库的正常使用
source ‘https://github.com/zyhDeveloper/ZYHModule.git‘
source ‘https://github.com/CocoaPods/Specs.git‘
添加:pod ‘XXModules‘
3、安装组件执行:pod install
七、私有库的更新迭代组件库当有新文件或者修改发生时,更新迭代执行:
git add .
git commit -m ‘更新描述‘
git push origin master
1、版本更新版本更新 这一步非常重要,为更新索引库做准备
git tag -a 0.2.0 -m "Release version 0.2.0"
git push origin --Tags
2、修改spec文件打开你的xx.podspec文件,将原本的版本号改为0.2.0,与刚刚的tag保持一致
git add .
git commit -m ‘更新描述‘
git push origin master 3、验证Specpod spec lint --allow-warnings4、更新索引库
// pod repo push 索引库名称 xxx.podspec
pod repo push ZYHModule XXModule.podspec --allow-warnings
// --no-repo-update 不更新本地索引库 ,因为刚刚已经自己手动更新过了,所以这里我们选择跳过更新
pod update --no-repo-update
八、子库Subspecs的使用如果我们只需要用到SDWebImage中的GIF功能,那么并不需要将整个SDWebImage都下载下来,在Podfile中将~~pod ‘SDWebImage‘~~ 改为 pod SDWebImage/GIF即可单独使用这一功能。
s.subspec ‘子库名称‘ do |别名| end
因为这里已经分离出子库了,所以s.source_files和s.dependency就不能这么使用了,需要我们在子库里分别指定,所以我们直接把原来的s.source_files和s.dependency都注释掉。写法参考如下
#s.source_files = ‘XXModule/Classes/**/*‘ # s.dependency ‘SDWebImage‘,‘~> 4.3.3‘
s.subspec ‘Cache‘ do |c|
c.source_files = ‘XXModule/Classes/Manager/**/*‘
c.dependency ‘SDWebImage‘,‘~> 4.3.3‘
end
s.subspec ‘category‘ do |c|
c.source_files = ‘XXModule/Classes/category/**/*‘
c.dependency ‘SDWebImage‘,‘~> 4.3.3‘
end
修改后再按之前的步骤更新索引库和组件库就可以了
pod spec lint --allow-warnings
pod repo push ZYHModule XXModule.podspec --allow-warnings
pod update --no-repo-update
如需在某个工程添加子库,可执行:
pod ‘XXModule/Manager‘
pod install
以上是内存溢出为你收集整理的iOS组件化开发构建详细步骤全部内容,希望文章能够帮你解决iOS组件化开发构建详细步骤所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)