iOS 创建私有库步骤
1、执行 pod 库的创建。
pob lib create AClassTest
回车之后出现以下几个选项
2、pod 库创建成功后,找到工程目录,移动到 Example 文件夹下
执行
pod install --no-repo-update
3、添加代码文件,如图 ATest
4、编辑配置文件 podspec
s.version: 版本号,与 tag 号保持一致
s.homepage:建议项目首页地址
s.source: 私有库 git 地址,可指定分支等
配置完成后,移到 Example 文件夹下, pod 更新一下
pod update --no-repo-update
5、运行测试,验证本地代码没问题
需要将项目发布到 git,并添加到 pod。
6、验证 pod 配置文件
为了确保 pod 配置文件没问题,在提交之前,需要验证一下
pod lib lint--allow-warnings
7、项目发布
将项目提交到 https://github.com/yuetianlu/AClassTest.git,此处省略步骤,分支节点应打 tag,与 s.version 一致。
8、创建 Spec 管理库
在终端执行 Specs 创建命令
pod repo add MySpec https://github.com/yuetianlu/MySpec.git
发布项目到管理库
pod repo push MySpec AClassTest.podspec --allow-warnings
可以去远端查看是否发布成功,或本地执行 pod repo 查看本地库
私有库发布成功。
9、检验结果
创建新工程 PrivatePodsExample,创建 Podfile 文件并安装。
打开示例工程,测试能否调用
可正常调用,发布成功。demo:https://github.com/yuetianlu/PrivatePodsExample.git
10、常见问题
当私有库A依赖了私有库B,在验证和push的时候带上两个sources源:
pod repo push MySpec AClassTest.podspec--allow-warnings --use-libraries --sources='https://github.com/CocoaPods/Specs.git,https://github.com/yuetianlu/MySpec.git'
参考文章:
https://www.jianshu.com/p/c8ea1f95717a
https://skyline75489.github.io/post/2016-3-19_ios_modularization_practice.html