组件化按照功能划分一般分为三种:
-
1.基础组件 (主要讲解)
-
2.功能组件
-
3.业务组件
远程私有库的实施步骤:
1.打开Xcode创建一个工程,如:TestDemo 工程


2. 把Classes做成远程私有库
2.1 创建一个私有索引库:https://coding.net/user/projects

2.2 添加一个spec私有仓库 (pod repo查看)
pod repo add NAME URL [BRANCH]
例子: pod repo add testSpec git@git.coding.net:chongyingnvhai/TestSpec.git
2.3 添加一个基础组件库

2.4 创建模板库 pod lib create TestClasses

2.5 将模板工程中的ReplaceMe.m文件替换为我们自己的类,重新pod install即可。


2.6 将本地的模板库push到远程私有库 (Sourcetree)
https://git.coding.net/chongyingnvhai/TestBase.git
git@git.coding.net:chongyingnvhai/TestBase.git

Tips:这里可通过sourcetree操作,也可通过终端git命令行操作。
1.git status
2.git add .
3.git commit -m 'commit init'
4.将本地库和远程库关联 git remote add origin <url>
5.提交到远程库 git push origin master
2.7修改podspec文件

2.8 本地验证podspec文件
本地验证 pod lib lint / pod lib lint --allow-warnings
远程验证 pod spec lint


注:本地验证不会验证s.source, 远程验证会验证远程地址及tag
2.9 打tag并推送到远程
2.9.1 关联远程地址: git remote add <name> <url>
例: git remote add origin https://git.coding.net/chongyingnvhai/TestClasses.git
2.9.2 打tag: git tag '0.1.0’
2.9.3 推送到远程:git push –tags
2.9.4 远程验证podspec文件 : pod spec lint

2.10 把podspec文件提交到我们自己的私有所有库
pod repo push 私有库的名字 podspec文件名字
例子:pod repo push testSpec TestClassesDemo.podspec

3. 搜索私有库
pod search TestClasses

4.在宿主工程中pod install私有库,按照效果如下:

至此,私有库的基础组件操作完毕。
网友评论