pod 更新自己的库,组件化

完整的建立一个工程:pod lib create 工程名

pod init:生成Podfile文件

************************方式一,利用github公开库,缺点只能共有,私有仓库要钱:

一、先将自己的库上传到git上

二、生成配置文件:(配置文件的具体配置,看下面第九点说明)

pod spec create 你项目名


三、开始生成版本:(以后更新版本只需要从此开始,但需要更改配置文件版本号)

git tag '1.0.0'

git push --tags (推送你的tag,用来标识这个tag时的内容,之后的改动都不影响这个tag)

提交我们的开源项目到cocoapods(这里是将你的库上传到cocopod官方spec索引源)

pod trunk push GlPopView.podspec --allow-warnings

四、(如果提示未注册trunk则注册:

pod trunk register 电子邮箱 '您的姓名' --description='macbook pro'

然后提示点击邮箱链接后:

查看自己注册信息:

五、查看自己注册的信息 

pod trunk me (可有可无的一步)

如果库没更新则:

六、如果是更新版本则需要,首次提交不需要

pod update


七、版本更新时更改pod配置文件时注意有两个地方:

s.version = "1.0.5"

s.source = { :git => "https://github.com/gleeeli/GlChartView-Master.git", :tag => s.version.to_s } //这后面tag指定了就要改,这里样式 s.version.to_s代表与上面的s.version一样的版本号


八、查看报错详情的方式:

pod spec lint GlPopView.podspec --verbose (打印错误信息)

其它配置可参考:(添加多个依赖库 ,静态库等)

https://blog.csdn.net/xiaofei125145/article/details/50673392

九、配置配置文件需要配置的选项

1.使用命令打开文件 

vim GlShowBigPhoto.podspec

2.下面是你配置文件 你需要打开注释或者核对的地方

s.version      = "1.0.3"

s.summary      = "写一些你库的说明"

s.homepage    = "https://github.com/gleeeli/GlShowBigPhoto"

s.license      = "MIT"

s.platform    = :ios, "9.0"

s.source      = { :git => "https://github.com/gleeeli/GlShowBigPhoto.git", :tag => s.version.to_s }

s.source_files  = "GlShowPhoto" //这里是你库的路径,这里把podspec文件当做相对路径,跟它同级直接写文件夹名字就行

s.requires_arc = true

s.dependency "Masonry" //这里添加依赖库,没有就不用管,有多个则复制多行

************************方式二,利用码云私有库组件化要点:

1.生成SSH公钥:https://gitee.com/help/articles/4181(好像不要也行)

2.创建好工程 pod lib create SwiftDevelopComm

此时工程里面有个Classes目录,将写好需要组件化的代码复制进去,此时在当前项目可以pod install看下项目是否增加了文件。

3.修改podspec文件

s.homepage = 'https://gitee.com/gleeeli'

s.source = { :git => 'https://gitee.com/gleeeli/SwiftDevelopComm.git', :tag => s.version.to_s }

s.source_files = 'SwiftDevelopComm/Classes/**/*'  这个目录自动生成,原理还是相对路径spec文件

4.将本地代码上传到码云去,并生成版本git tag 0.01 ...

5. 校验是否格式有错误

pod lib lint --allow-warnings 对本地文件校验,看podspec是否符合规范

方式1校验:

pod spec lint --use-libraries --allow-warnings 远程校验是否有错误

方式2校验(推荐):

pod spec lint GlComm.podspec --allow-warnings  --swift-version=5.0  --sources='https://gitee.com/gleeeli/GlSpecs.git,https://github.com/CocoaPods/Specs' 

若引用到其他模块私有库时:需要加上 -sources

6.在码云上创建自己的专用spec索引库,公司一般都有自己的索引库,也是这个步骤

方式一(不推荐,不好归类):

pod repo add SwiftDevelopComm https://gitee.com/gleeeli/SwiftDevelopComm.git

方式二(推荐):

在本地添加一个空的源-索引库,(添加前你需要创建这个索引项目:https://gitee.com/gleeeli/GlSpecs.git)

pod repo add GlSpecs https://gitee.com/gleeeli/GlSpecs.git

将自己的GlComm库推到自己的GlSpecs索引库

pod repo push GlSpecs GlComm.podspec  --allow-warnings  --swift-version=5.0  --sources='https://gitee.com/gleeeli/GlSpecs.git,https://github.com/CocoaPods/Specs'

若引用到其他模块私有库时:需要加上 -sources

7.引入组件

podfile文件:

如果自己的库推送到了官方trunk的CocoaPods索引库,就加上这句:

 source ‘https://github.com/CocoaPods/Specs.git’

如果自己的库推送到了自己的索引源就加上这句:

 source ‘https://gitee.com/gleeeli/GlSpecs.git’

pod 'SwiftDevelopComm'

参考网址:https://www.jianshu.com/p/2030de45055e

https://www.jianshu.com/p/9cd894b1cc50

你可能感兴趣的:(pod 更新自己的库,组件化)