Swift 組件化 cocoapods使用私有庫 踩坑記

步驟歸納:

1 創(chuàng)建遠(yuǎn)程索引庫

2 將遠(yuǎn)程索引庫添加到本地

3 創(chuàng)建本地私有庫,完成測試

4 修改Spec文件

5 提交私有庫代碼并增加tag

6 提交spec至私有索引庫

7 測試

第一步? 第二步請自行百度 這里不贅述了

3:創(chuàng)建本地私有庫 ( 此處以 ZYExtension為例)

cd 到指定目錄下,然后 pod lib create?ZYExtension


以上配置針對個人需要進(jìn)行配置,此處因為我本人是希望創(chuàng)建一個swift的遠(yuǎn)程私有庫,所以此處語言我選擇了Swift。配置完成之后,會自動打開一個響應(yīng)的Example項目。該項目如下:

將需要放到該私有庫的文件替換Classes文件夾中的Replace.swift

cd 到Example目錄下 ?執(zhí)行pod install命令,在Example中進(jìn)行測試,確保組件可用。

以下是Spec文件簡單介紹 : 由于項目需要支持到swift 4.0 所以需要指定版本?

s.source 這個地方要填寫 遠(yuǎn)程倉庫地址 而不是本地私有庫 (默認(rèn)生成的是本地私有庫地址)

提交私有庫代碼并增加tag

?將代碼提交到組件遠(yuǎn)程倉庫,常用的git命令,git工具就不說了

git add .

git commit -m '第一次提交'

git add origin https://github.com/PZYan/TestCourse.git

遇到錯誤 解決如下

?! [rejected]? ? ? ? master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/PZYan/TestCourse.git'

提交私有庫代碼并增加tag??


指定版本??echo "4.0" > .swift-version

如果有私有庫添加進(jìn)去私有庫??sources='https://github.com/CocoaPods/Specs.git,私有庫'

[!] 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上的組件庫地址 不要搞混淆了,??

成功如下:

錯誤一

-> 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

錯誤二

?->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)建個子分子 然后切換到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



恭喜你 成功了啦?。。。?/p>


參考資料如下:

swift創(chuàng)建私有庫

repo錯誤解決

iOS組件化開發(fā)

Pod:解決錯誤

git刪除分支

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容