写在前面
之前也有把库上传到githup,并支持pod,
最近更新了几次最新的三方库,总结记录一下
复制代码
步骤1 创建pod配置文件
cd 到你文件的目录下,执行 pod init (假设你已经安装了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 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
//再重新提交即可
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 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。
复制代码
**大致也分了几个小步骤:**
s.version = "1.0.1"
s.source = { :git => "https://github.com/dudongge/DDGScreenShot.git", :tag => "1.0.1" }
git tag 1.0.1 (添加tag)
git push --tags (推送tag到远程)
git push origin master (推送到远程到代码仓库)
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 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...
大功告成!!!!!
复制代码