iOS软件开发 - 制作自己的私有库发布到cocoapods

 
  

这里以YWChooseAddressView为例

1、提交code到git仓库中,并打上tag版本号 注意,如果是用git工具提交的demo,可直接在github上去发布realese版本

git tag -a 1.0.0
git push origin master

先看看我的目录结构(包含测试demo.podspecLICENSE等文件):


在这里我还是要推荐下我自己建的iOS开发学习群:680565220,群里都是学ios开发的,如果你正在学习ios ,小编欢迎你加入,今天分享的这个案例已经上传到群文件,大家都是软件开发党,不定期分享干货(只有iOS软件开发相关的),包括我自己整理的一份2018最新的iOS进阶资料和高级开发教程,欢迎进阶中和进想深入iOS的小伙伴。
屏幕快照 2018-01-25 下午4.47.32.png

2、创建 podspec执行

pod spec create YWChooseAddressView

2、配置YWChooseAddressView.podspec文件,直接打开或者利用vim编辑都行,注意""标点符号即可

Pod::Spec.new do |s|

  s.name         = "YWChooseAddressView"
  s.version      = "1.0.3"
  s.summary      = "地区选择器"
  s.description  = <<-DESC
                  高仿京东地区选择器
                 DESC
  s.homepage     = "https://github.com/90candy/YWChooseAddressView"
  s.license              = { :type => "MIT", :file => "LICENSE" }
  s.author             = { "90Candy" => "[email protected]" }
  s.social_media_url   = "https://www.jianshu.com/u/0f7d26d766f4"
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/90candy/YWChooseAddressView.git", :tag => s.version }
  s.source_files  = "YWChooseAddress/YWChooseAddressView/**/*.{h,m}"
  s.resources = "YWChooseAddress/YWChooseAddressView/Resource/*.{png,json}"
  s.requires_arc = true
  s.dependency "FMDB", "~> 2.7.2"
end

3、验证podspec文件

pod spec lint YWChooseAddressView.podspec --verbose

4、如果验证通过则会出现success 字样,则可发布到cocoapod

发布之前需注册发布者信息:

5、注册trunk执行:

pod trunk register 90candy.com@gmail.com  "阿唯不知道"

6、注册之后在对应的邮箱中去点击链接激活,然后执行:

pod trunk me // 可查看你的注册信息包括(name、email、since、Pods、sessions)

7、发布操作到CocoaPod

pod trunk push YWChooseAddressView.podspec --verbose

8、发布成功后显示如下:

 �  Congrats

 ?  YWChooseAddressView (1.0.3) successfully published
 ?  January 25th, 01:32
 �  https://cocoapods.org/pods/YWChooseAddressView
 ?  Tell your friends!

9、添加其他维护者(如果你的pod库是由多人维护的)

pod trunk add-owner YWChooseAddressView yw@gmail.com

无法搜索到怎么办?继续往下看


10、如果发布了自己的私有库无法搜索到

成功发布了自己的私有库以后 pod search YWChooseAddressView 无法搜索到类库的解决办法

11、先执行 pod setup 成功后会生成:

~/Library/Caches/CocoaPods/search_index.jso 文件

12、然后执行rm ~/Library/Caches/CocoaPods/search_index.json 删除该文件:

~/Library/Caches/CocoaPods/search_index.json 文件删除成功后不会有任何提示,继续执行下一步即可

13、之后就可以直接执行命令pod search XXX搜索,这时候会重新生成 :

~/Library/Caches/CocoaPods/search_index.json 文件

14、实际操作命令记录:

MacBook-Pro:YWChooseAddress Candy$ pod search YWChoose
[!] Unable to find a pod with name, author, summary, or description matching `YWChoose`
MacBook-Pro:YWChooseAddress Candy$ pod setup 
Setting up CocoaPods master repo
  $ /usr/local/bin/git -C /Users/apple/.cocoapods/repos/master fetch origin
  --progress
  remote: Counting objects: 105, done.        
  remote: Compressing objects: 100% (100/100), done.        
  remote: Total 105 (delta 66), reused 0 (delta 0), pack-reused 0        
  Receiving objects: 100% (105/105), 11.83 KiB | 0 bytes/s, done.
  Resolving deltas: 100% (66/66), completed with 40 local objects.
  From https://github.com/CocoaPods/Specs
     ce8f7b14f05..e643cf8834a  master     -> origin/master
  $ /usr/local/bin/git -C /Users/apple/.cocoapods/repos/master rev-parse
  --abbrev-ref HEAD
  master
  $ /usr/local/bin/git -C /Users/apple/.cocoapods/repos/master reset --hard
  origin/master
  HEAD is now at e643cf8834a [Add] LBCollectionViewLayout 1.0.4
Setup completed
MacBook-Pro:YWChooseAddress Candy$ rm  ~/Library/Caches/CocoaPods/search_index.json
MacBook-Pro:YWChooseAddress Candy$ pod search YWChooseAddressView
Creating search index for spec repo 'macdownapp'.. Done!
Creating search index for spec repo 'master'.. Done!

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!



你可能感兴趣的:(iOS软件开发 - 制作自己的私有库发布到cocoapods)