已碼云為例,創(chuàng)建自己的私有pods庫
一、創(chuàng)建項目
1、創(chuàng)建碼云git項目
創(chuàng)建HZPodRepos.png
HZPodRepos.png
2、clone到本地
git clone git@gitee.com:lovekisser/HZPodRepos.git
clone success.png
3、初始化項目,coding完畢,然后把想要保存的文件copy到文件夾下。
image.png
4、給倉庫創(chuàng)建一個podspec文件
pod spec create HZPodRepos git@gitee.com:lovekisser/HZPodRepos.git
image.png
image.png
5、編輯HZPodRepos.podspec文件
目錄中不做分層顯示
Pod::Spec.new do |s|
s.name = "HZPodRepos" #名稱
s.version = "0.0.1" #版本號
s.summary = "一個簡短的簡介" #簡介
s.description = <<-DESC #詳細介紹
這是一個私人倉庫(介紹一定要寫在<<-DESC和DESC之間)
DESC
s.homepage = "https://gitee.com/lovekisser/HZPodRepos"#主頁,這里要填寫可以訪問到的地址,不然驗證不通過
s.license = "MIT" #開源協(xié)議(這里一定要創(chuàng)建,下面會說)
s.author = { "zhouhao" => "zhouhao_0827@126.com" } #作者信息
s.platform = :ios, "8.0" #支持的平臺及版本
s.source = { :git => "https://gitee.com/lovekisser/HZPodRepos.git", :tag => "0.0.1" } #項目地址,這里不支持ssh的地址,驗證不通過,只支持HTTP和HTTPS,最好使用HTTPS
s.source_files = "HZPodRepos", 'HZPodTest/Classes/**/*' #代碼源文件地址,**/*表示Classes目錄及其子目錄下所有文件,如果有多個目錄下則用逗號分開,如果需要在項目中分組顯示,這里也要做相應(yīng)的設(shè)置
s.frameworks = 'UIKit' #所需的framework,多個用逗號隔開
s.requires_arc = true #是否使用arc
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" #截圖
end
目錄中做分層顯示
pod spec create HZPodRepos git@gitee.com:lovekisser/HZPodRepos.git
image.png
image.png
5、編輯HZPodRepos.podspec文件
目錄中不做分層顯示
Pod::Spec.new do |s|
s.name = "HZPodRepos" #名稱
s.version = "0.0.1" #版本號
s.summary = "一個簡短的簡介" #簡介
s.description = <<-DESC #詳細介紹
這是一個私人倉庫(介紹一定要寫在<<-DESC和DESC之間)
DESC
s.homepage = "https://gitee.com/lovekisser/HZPodRepos"#主頁,這里要填寫可以訪問到的地址,不然驗證不通過
s.license = "MIT" #開源協(xié)議(這里一定要創(chuàng)建,下面會說)
s.author = { "zhouhao" => "zhouhao_0827@126.com" } #作者信息
s.platform = :ios, "8.0" #支持的平臺及版本
s.source = { :git => "https://gitee.com/lovekisser/HZPodRepos.git", :tag => "0.0.1" } #項目地址,這里不支持ssh的地址,驗證不通過,只支持HTTP和HTTPS,最好使用HTTPS
s.source_files = "HZPodRepos", 'HZPodTest/Classes/**/*' #代碼源文件地址,**/*表示Classes目錄及其子目錄下所有文件,如果有多個目錄下則用逗號分開,如果需要在項目中分組顯示,這里也要做相應(yīng)的設(shè)置
s.frameworks = 'UIKit' #所需的framework,多個用逗號隔開
s.requires_arc = true #是否使用arc
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" #截圖
# UIView 和 EasyLog 在工程中以子目錄顯示
s.subspec 'UIView' do |ss|
ss.source_files = 'ZXCategory/UIView/*.{h,m}'
end
s.subspec 'EasyLog' do |ss|
ss.source_files = 'ZXCategory/EasyLog/*.{h,m}'
end
end
6、創(chuàng)建LICENSE,并寫上相應(yīng)協(xié)議內(nèi)容,隨便寫,百度都有
touch LICENSE
image.png
7、然后把code push到git,并且設(shè)置tag
git push origin --tags
8、檢查HZPodRepos.podspec文件是否編寫成功
pod lib lint
出現(xiàn)下面情況,說明文件設(shè)置有問題,按照提示修改即可
-> HZPodRepos (0.0.1)
- ERROR | license: Sample license type.
- WARN | homepage: The homepage has not been updated from default
- ERROR | source: The Git source still contains the example URL.
- WARN | summary: The summary is not meaningful.
- ERROR | description: The description is empty.
- WARN | url: There was a problem validating the URL http://EXAMPLE/HZPodRepos.
- ERROR | [OSX] unknown: Encountered an unknown error (The `HZPodRepos` pod failed to validate due to 3 errors:
- ERROR | license: Sample license type.
- WARN | homepage: The homepage has not been updated from default
- ERROR | source: The Git source still contains the example URL.
- WARN | summary: The summary is not meaningful.
- ERROR | description: The description is empty.
) during validation.
成功.png
提示
到目前為止,個人私有庫就創(chuàng)建好了。按照下面方式就可以使用了。
source 'https://gitee.com/lovekisser/HZPodRepos.git'
platform :ios, '8.0'
use_frameworks!
target ‘demo’ do
pod 'HZPodRepos', :git => 'https://gitee.com/lovekisser/HZPodRepos.git'
end
二、把創(chuàng)建好的庫上傳給cocoapods
1、pod trunk 注冊
pod trunk register zhouhao_0827@126.com 'HZPodRepos'
2、然后進入郵箱確認
3、確認成功與否
pod trunk me
image.png
4、上傳HZPodRepos.podspec 到 CocoaPods/repo
pod trunk push HZPodRepos.podspec
success.png
5、然后就可以使用了
pod repo update
pod search HZPodRepos