美文网首页
iOS 创建 CocoaPods 私有库

iOS 创建 CocoaPods 私有库

作者: yue_kyy | 来源:发表于2019-03-14 10:35 被阅读0次

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

验证pod库

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 文件并安装。

Podfile 文件 pod install

打开示例工程,测试能否调用

主工程展示

可正常调用,发布成功。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

https://www.jianshu.com/p/475d6b6d5600

相关错误解决:http://www.php-master.com/post/356537.html

相关文章

网友评论

      本文标题:iOS 创建 CocoaPods 私有库

      本文链接:https://www.haomeiwen.com/subject/cdtqmqtx.html