制作步驟
1. 創(chuàng)建遠程倉庫
2. 將倉庫克隆到本地
git clone https://github.com/a-stupid-wood/WKBCategory.git
3. 創(chuàng)建.podspes文件
pod spec create WKBCategory
4. 本地目錄中創(chuàng)建共享的類
5. 編輯podspec文件
Pod::Spec.new do |s|
s.name = "WKBCategory"
s.version = "0.1.2"
s.summary = "WKBCategory"
s.description = "封裝自己項目常用到的類別"
s.homepage = "https://github.com/a-stupid-wood/WKBCategory"
s.license = "MIT"
s.author = { "Kerwin" => "13763072736@163.com" }
s.source = { :git => "https://github.com/a-stupid-wood/WKBCategory.git", :tag => "#{s.version}" }
s.requires_arc = true
s.platform = :ios, "9.0"
s.source_files = "WKBCategory/WKBCategory.h"
s.frameworks = 'Foundation', 'UIKit'
s.subspec 'UIView+wkb' do |ss|
ss.source_files = "WKBCategory/UIView+wkb/*.{h,m}"
end
s.subspec 'NSString+wkb' do |ss|
ss.source_files = "WKBCategory/NSString+wkb/*.{h,m}"
end
s.subspec 'UIButton+wkb' do |ss|
ss.source_files = "WKBCategory/UIButton+wkb/*.{h,m}"
end
s.subspec 'UIColor+wkb' do |ss|
ss.source_files = "WKBCategory/UIColor+wkb/*.{h,m}"
end
s.subspec 'UIImage+wkb' do |ss|
ss.source_files = "WKBCategory/UIImage+wkb/*.{h,m}"
end
s.subspec 'NSDate+wkb' do |ss|
ss.source_files = "WKBCategory/NSDate+wkb/*.{h,m}"
end
end
6. 上傳到遠程倉庫并打tag
git add .
git commit -m "提交描述"
git push -u origin master
git tag 0.1.2
git push --tags
7. 驗證podspec
pod spec lint
驗證成功會出現(xiàn)以下提示:
Analyzed 1 podspec.
WKBCategory.podspec passed validation.
8. pod主干注冊
pod trunk register 13763072736@163.com 'flow' --verbose
9. 發(fā)布pod庫
pod trunk push WKBCategory.podspec --allow-warnings
這個時間比較久霞幅,成功完成之后就可以在終端通過 pod search 搜到你的 cocoapods 庫
可能會遇到的錯誤
執(zhí)行 pod trunk push 命令時掏秩,可能會出現(xiàn)下面的錯誤
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent ...
解決辦法是執(zhí)行下面的命令
pod trunk register 13763072736@163.com 'flow' --verbose
然后在自己郵箱里面去點擊狼纬,那個郵件里面的連接背率,就可以了
git 的常用命令
git clone 遠端倉庫git地址
git init //初始化一個空的 git 倉庫
git remote add origin 遠端倉庫git地址 //給本地倉庫添加遠程倉庫
git pull origin master //拉取遠程倉庫 master 分支的代碼更新本地倉庫代碼
git add . //將所有修改和新添的文件存到緩存區(qū)
git commit -m "提交描述" //將緩存區(qū)的代碼提交到本地倉庫
git push -u origin master //將本地倉庫的代碼推送到遠程倉庫