步驟歸納:
1 創(chuàng)建遠(yuǎn)程索引庫(kù)
2 將遠(yuǎn)程索引庫(kù)添加到本地
3 創(chuàng)建本地私有庫(kù)罗洗,完成測(cè)試
4 修改Spec文件
5 提交私有庫(kù)代碼并增加tag
6 提交spec至私有索引庫(kù)
7 測(cè)試
第一步? 第二步請(qǐng)自行百度 這里不贅述了
3:創(chuàng)建本地私有庫(kù) ( 此處以 ZYExtension為例)
cd 到指定目錄下伺帘,然后 pod lib create?ZYExtension
以上配置針對(duì)個(gè)人需要進(jìn)行配置里烦,此處因?yàn)槲冶救耸窍M麆?chuàng)建一個(gè)swift的遠(yuǎn)程私有庫(kù)匪凡,所以此處語(yǔ)言我選擇了Swift。配置完成之后捌袜,會(huì)自動(dòng)打開一個(gè)響應(yīng)的Example項(xiàng)目琅轧。該項(xiàng)目如下:
將需要放到該私有庫(kù)的文件替換Classes文件夾中的Replace.swift
cd 到Example目錄下 ?執(zhí)行pod install命令析孽,在Example中進(jìn)行測(cè)試,確保組件可用只怎。
以下是Spec文件簡(jiǎn)單介紹 : 由于項(xiàng)目需要支持到swift 4.0 所以需要指定版本?
s.source 這個(gè)地方要填寫 遠(yuǎn)程倉(cāng)庫(kù)地址 而不是本地私有庫(kù) (默認(rèn)生成的是本地私有庫(kù)地址)
提交私有庫(kù)代碼并增加tag
?將代碼提交到組件遠(yuǎn)程倉(cāng)庫(kù)袜瞬,常用的git命令,git工具就不說(shuō)了
git add .
git commit -m '第一次提交'
git add origin https://github.com/PZYan/TestCourse.git
遇到錯(cuò)誤 解決如下
?! [rejected]? ? ? ? master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/PZYan/TestCourse.git'
提交私有庫(kù)代碼并增加tag??
指定版本??echo "4.0" > .swift-version
如果有私有庫(kù)添加進(jìn)去私有庫(kù)??sources='https://github.com/CocoaPods/Specs.git,私有庫(kù)'
[!] ZYExtension did not pass validation, due to 11 warnings (but you can use `--allow-warnings` to ignore them).You can use the `--no-clean` option to inspect any issue.
解決方案:pod lib lint --sources='https://github.com/CocoaPods/Specs.git,http://123.57.226.216/app/YBSSpec.git' --allow-warnings
注:?'http://123.57.226.216/app/YBSSpec.git'? 是公司自己搭建的GitLib上的組件庫(kù)地址 不要搞混淆了,??
成功如下:
錯(cuò)誤一
-> ZYExtension (0.1.0)? ? ? ? ? ? ?
? ? - WARN? | description: The description is shorter than the summary.
? ? - WARN? | url: The URL (https://github.com/PZYan/ZYExtension) is not reachable.
? ? - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/PZYan/TestCourse.git /var/folders/6j/dk00xh8j7kj9rvs4mxvp_xqc0000gn/T/d20200530-16312-oxjk8m --template= --single-branch --depth 1 --branch 0.1.0
Cloning into '/var/folders/6j/dk00xh8j7kj9rvs4mxvp_xqc0000gn/T/d20200530-16312-oxjk8m'...
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
錯(cuò)誤二
?->ZYExtension (0.1.0)
? ? - WARN? | url: The URL (https://github.com/PZYan/ZYExtension) is not reachable.
? ? - ERROR | [iOS] unknown: Encountered an unknown error (Pod::DSLError) during validation.
解決如下?
創(chuàng)建個(gè)子分子 然后切換到master 再刪除子分子? 再重新pod spec lint? 就可以成功了
?git branch -t deve
git chechout master
git branch --delete deve
git add .
git commit -m '上傳修改'
git push origin master
git tag '0.1.1'
git push --tags
pod spec lint --private --sources='https://github.com/CocoaPods/Specs.git,http://123.57.226.216/app/YBSSpec.git' --allow-warnings?
最后
pod repo push TestCourse ZYExtension.podspec --allow-warnings
恭喜你 成功了啦I肀ぁ5擞取!贴谎!
參考資料如下: