写在前面
之前也有把库上传到githup,并支持pod,
最近更新了几次最新的三方库,总结记录一下
步骤1 创建pod配置文件
cd 到你文件的目录下 到你文件的目录下,执行 pod spec create DDGScreenShot 会生成一个DDGScreenShot.podspec 文件
(假设你已经安装了pod,并且可以正常运行)
生成Podfile文件, 我们需要对其进行相应的配置
配置的地方不多
s.name = "DDGScreenShot" //项目名称
s.version = "1.0.0" //项目版本
s.summary = "A short description of DDGScreenShot." //项目介绍
s.description = <<-DESC //项目详细介绍(写在两DESC中间)
图片生成工具,一句代码,即可生成图片,并对图片进行简单修饰
DESC
s.homepage = "https://github.com/dudongge/DDGScreenShot/tree/master" //链接地址
s.license = "MIT" //开源协议
s.author = { "dudongge" => "532835032@qq.com" } //作者信息
s.platform = :ios //平台系统
s.platform = :ios, "9.0" //兼容最低版本
s.source = { :git => "https://github.com/dudongge/DDGScreenShot.git", :tag => "1.0.0" } //资源文件地址 这个版本号要和以前的一致
s.source_files = "DDGScreenShot/DDGScreenShot/", "Classes/**/*.{h,m}" //资源文件
2 把代码push 到pod 远程库
#提交git 版本 tag //注:只要spec文件被修改,就必须重新执行如下命令
git tag 1.0.0 (添加tag)
git push --tags (推送tag到远程)
git push origin master (推送到远程到代码仓库)
//若想修改
// 删除本地tag
git tag -d 1.0.0
// 删除远程tag
git push origin -d tag 1.0.0
//再重新提交即可
#提交之前先验证.podspec文件是否合法
pod spec lint DDGScreenShot.podspec
pod spec lint DDGScreenShot.podspec --allow-warnings (忽略警告)
# 例如 下面只有警告,可以忽略,有错误,就按照上述徐哦呜提示修改即可
pod trunk push DDGScreenShot.podspec
Updating spec repo `master`
CocoaPods 1.5.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.0.beta.1
Validating podspec
-> DDGScreenShot (1.0.2)
- WARN | summary: The summary is not meaningful.
- WARN | description: The description is shorter than the summary.
# 提交到 pod
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
# 若是第一次提交 会提示你去注册邮箱(已注册过,可以忽略)
pod trunk register 邮箱地址 "用户名" --description="macbook pro"
之后会有一封带有验证链接的邮件发送到你输入的邮箱,点击验证后就可以回来终端继续提交操作了。
#再次push 代码
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
3 提交成功和查看
# 若出现以下操作,那个恭喜你,当然提交后要等待一段时间
🎉 Congrats
🚀 DDGScreenShot (1.0.1) successfully published
📅 April 2nd, 18:55
🌎 https://cocoapods.org/pods/DDGScreenShot
👍 Tell your friends!
# 尽管已经提交成功,pod search DDGScreenShot 还是提示会找不到,这个时候,需要清理以下CocoaPods缓存
pod setup成功后会生成~/Library/Caches/CocoaPods/search_index.json文件。
终端输入rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后再执行pod search DDGScreenShot
> DDGScreenShot (1.0.0)
A short description of DDGScreenShot.
pod 'DDGScreenShot', '~> 1.0.0'
- Homepage: https://github.com/dudongge/DDGScreenShot/tree/master
- Source: https://github.com/dudongge/DDGScreenShot.git
- Versions: 1.0.0 [master repo]
# 是不是顿时感觉自己离天堂的距离进了点。
更新自己已有的库
时间久了,自己的库的内容也要补充,当然,这就涉及到版本升级,
当然升级前有些准备工作,比如将最新的代码提交到github上,本文不涉及这方面内容,
会重新写一篇文章(可以参考下Githud Desktop )桌面软件,其实 so easy。
**大致也分了几个小步骤:**
# 1 更改 podspec 文件,改的地方比较的少
s.version = "1.0.1"
s.source = { :git => "https://github.com/dudongge/DDGScreenShot.git", :tag => "1.0.1" }
# 2 提交新的 tag
git tag 1.0.1 (添加tag)
git push --tags (推送tag到远程)
git push origin master (推送到远程到代码仓库)
# 3 push 代码
pod trunk push DDGScreenShot.podspec
pod trunk push DDGScreenShot.podspec --allow-warnings
。。。。。。一段时间之后
-------------------------------------------------------------------------------
🎉 Congrats
🚀 DDGScreenShot (1.0.1) successfully published
📅 April 3nd, 13:55
🌎 https://cocoapods.org/pods/DDGScreenShot
👍 Tell your friends!
那么,就更新成功了
rm ~/Library/Caches/CocoaPods/search_index.json
pod setup : 初始化
pod repo update : 更新仓库
pod search DDGScreenShot
-> DDGScreenShot (1.0.1)
A short description of DDGScreenShot.
pod 'DDGScreenShot', '~> 1.0.1'
- Homepage: https://github.com/dudongge/DDGScreenShot/tree/master
- Source: https://github.com/dudongge/DDGScreenShot.git
- Versions: 1.0.1, 1.0.0 [master repo]
...skipping...
大功告成!!!!!
网友评论