CocoaPods创建公有和私有库

2017-10-18  本文已影响2人  不離

一、使用CocoaPods创建公有库(也就是能search到,并且能pod install)

1.在github上创建一个new repository

屏幕快照 2017-10-18 下午9.15.42.png

2. clone创建好的项目保存在桌面(使用github客户端操作)

3.往clone下来的文件夹中添加相关文件

屏幕快照 2017-10-18 下午9.30.17.png

4.使用pod trunk发布程序,需要注册

注册
接收邮件
查看个人信息
 - Name:     zhangxiaoyuheshui
  - Email:    xxxxxx@qq.com
  - Since:    October 16th, 21:16
  - Pods:
    - None // 注释:此处新注册是没有pods的
  - Sessions:
    - October 16th, 21:16 - February 23rd, 2018 07:40. IP: XX.XX.111.222
    Description: MAC

5.创建podspec文件

屏幕快照 2017-10-18 下午9.35.48.png
填写podspec的内容
Pod::Spec.new do |s|
  s.name            = "TestLibrary"
  s.version         = "0.0.1"
  s.summary     = "简单的描述"
  s.description   = "较为详细的描述"
  s.homepage     = "第一步创建仓库的地址,比如:https://github.com/zhangxiaoyuheshui/TestLibrary"
  s.license      = "MIT"
  s.author             = { "MAC" => "XXXXXX@qq.com" }
  s.source       = { :git => "https://github.com/zhangxiaoyuheshui/TestLibrary.git", :tag => s.version }
  s.platform     = :ios, "8.0"
  s.source_files  = "TestLibrary", "TestLibrary/TestLibrary"
  s.framework  = "UIKit"
  s.requires_arc = true
end
现在podspec需要有tag,所以执行以下命令
检查podspec的内容

6.发布podspec

创建私有库

1.创建私有Spec Repo

2.创建pod私有组件库

3.将podspec加入私有Sepc repo中

4.查找和使用内部组件库

source 'coding git服务器的地址'  
platform :ios, '9.0'
   target "test" do
       pod '你的库'
end

5.补充

-私有repo的构建形式有两种, 一种是私有git服务器上面创建,一种是本机创建.本机创建请参考官方文档:Private Pods, 这里介绍的是在coding的git服务器上面创建整个服务的方式.

参考链接

CocoaPods创建公有和私有Pod库方法总结
使用Cocoapods创建私有podspec

上一篇 下一篇

猜你喜欢

热点阅读