前言
因?yàn)橐婚_始學(xué)組件化的時(shí)候把一部分公司代碼給搞到了 cocoapods 上,(雖然是私有倉(cāng)庫別人無法查看,雖然代碼無關(guān)緊要)但是被公司信息安全的那幫同事給掃描到了,然后勒令刪除,哎,都怪當(dāng)年不懂事,自己造的孽呀(備注:此處只能在 cocoapods 看到 .podspec 中內(nèi)容和 git 地址,除非知道 git 私有倉(cāng)庫密碼,否則看不了代碼,畢竟是私有倉(cāng)庫)
上篇文章iOS 組件化的創(chuàng)建 - 創(chuàng)建 cocoapods 庫
刪除已經(jīng)推送到 cocoapods 上的倉(cāng)庫
一、倉(cāng)庫是放到Cocoapods 上了
pod search YLAppTool
下面的 Versions 中的 中括號(hào)里面是 repo 地址,此處是我私人倉(cāng)庫,[cocoapods repo] 才是 cocoapods 倉(cāng)庫

1、刪除已發(fā)布的庫的某一版本
前提是cocopods 上的倉(cāng)庫存在,你 pod search 搜索到的版本號(hào),并不是 cocoapods 推送的版本號(hào),而是你 git 倉(cāng)庫的版本號(hào)!
pod trunk delete YLAppTool 1.0.0
二 刪除倉(cāng)庫問題解決:
1、如果不帶版本號(hào)會(huì)報(bào)錯(cuò):
[!] Please specify a version.
[!] 請(qǐng)指定一個(gè)版本。

2、身份令牌無效
WARNING: It is generally considered bad behavior to remove versions of a Pod that others are depending on!
Please consider using the `deprecate` command instead.
Are you sure you want to delete this Pod version?
> YES
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
警告:刪除其他人依賴的 Pod 版本通常被認(rèn)為是不良行為!
請(qǐng)考慮使用 “棄權(quán)” 命令。
是否確實(shí)要?jiǎng)h除此 Pod 版本?
> 對(duì)
[!] 身份驗(yàn)證令牌無效或未驗(yàn)證。請(qǐng)使用發(fā)送的電子郵件進(jìn)行驗(yàn)證,或注冊(cè)新會(huì)話。

解決辦法:
自己 s.author 里面的郵箱
pod trunk register '1219876794@qq.com' '1219876794@qq.com' --description=''

驗(yàn)證發(fā)送成功之后,你郵箱會(huì)收到這樣一份郵件,點(diǎn)擊鏈接就好,原文是英文,我給翻譯了一下

3、 [!] No pod version found with the specified version.(找不到具有指定版本的 pod 版本。)
繼續(xù)刪除已發(fā)布的庫的某一版本
pod trunk delete YLAppTool 1.0.0
[!] No pod version found with the specified version.(找不到具有指定版本的 pod 版本。)
WARNING: It is generally considered bad behavior to remove versions of a Pod that others are depending on!
Please consider using the `deprecate` command instead.
Are you sure you want to delete this Pod version?
> yes
[!] No pod version found with the specified version.
警告:刪除其他人依賴的 Pod 版本通常被認(rèn)為是不良行為!
請(qǐng)考慮使用 “棄權(quán)” 命令。
是否確實(shí)要?jiǎng)h除此 Pod 版本?
> 對(duì)
[!] 找不到具有指定版本的 pod 版本。

但是明明存在,為什么不能刪除呢?難道是因?yàn)橹挥羞@一個(gè)版本?結(jié)果事實(shí)真像竟然是這:幸虧保留之前的截圖,做了記錄

刪除成功
pod trunk delete YLAppTool 0.1.2

[!] The version is already deleted.
[!] 該版本已被刪除。
終于把它給干掉了,搜索到的 1.0.0 版本,是因?yàn)槲覀冺?xiàng)目的正式版本是 1.0.0,但是推送到 cocoapods 上的并不是 1.0.0 版本,而且 cocoapods 上不僅僅有一個(gè)版本!0.1.2 、 0.1.4
4、怎么判斷已經(jīng)把所有版本刪除完了?
如果還有刪除當(dāng)前版本成功,會(huì)提示The version is already deleted. (存在或之前存在都會(huì)提示)如果當(dāng)前版本是最后一個(gè)版本號(hào),也依然會(huì)這樣提示
如果刪除任意版本都提示:[!] No pod found with the specified name.,那就是該庫已經(jīng)被刪除了
WARNING: It is generally considered bad behavior to remove versions of a Pod that others are depending on!
Please consider using the `deprecate` command instead.
Are you sure you want to delete this Pod version?
> y
[!] No pod found with the specified name.
警告:刪除其他人依賴的 Pod 版本通常被認(rèn)為是不良行為!
請(qǐng)考慮使用 “棄權(quán)” 命令。
是否確實(shí)要?jiǎng)h除此 Pod 版本?
>y
[!] 未找到具有指定名稱的 pod。
5、判斷方法 2
可以把它放到你的podfile 中,pod YLAppTool, 當(dāng)然,你需要更新 pod repo update,可能會(huì)有延遲,當(dāng)有如下提示:證明該庫已不存在
[!] Unable to find a specification for `YLAppTool`
You have either:
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
[!] 找不到 'YLAppTool' 的規(guī)范 `
你有:
* 輸入了錯(cuò)誤的名稱或版本。
* 未將承載 Podspec 的源 repo 添加到您的 Podfile 中。
版本號(hào)未知怎么辦? 可以把它放到你的項(xiàng)目 podfile 中,pod YLAppTool,這樣就可以知道了!但是會(huì)有延遲,
最后,如果 pod search 還能搜索到!
此處是徹底刪除倉(cāng)庫,不僅僅是刪除某一個(gè)版本號(hào)
1、搞了半天發(fā)現(xiàn)。為什么 pod search還是可以搜索到,但是 pod 上已經(jīng)說沒有這個(gè)庫了,不管是 pod install 還是 pod update 都找不到這個(gè)庫了,
2、倉(cāng)庫刪除掉了是肯定的,毋庸置疑,這是緩存的原因,是 cocoapods 緩存的原因
3、如果你要驗(yàn)證,把 library 里面的 chaches 中 cocoapods 和 .cocoapods 全部刪除,卸載 cocoapods,重新安裝,再去搜索就沒了,(此處我已驗(yàn)證)上圖
4、第三種驗(yàn)證方法是有一定問題的,我剛剛驗(yàn)證:你要先看是哪個(gè)倉(cāng)庫搜到的,如果是非 cocoapod 倉(cāng)庫,請(qǐng)先把該倉(cāng)庫刪除 以及 caches search_index.json 刪除,再重新搜索 因?yàn)樗接袀}(cāng)庫會(huì)對(duì) cocoapods 倉(cāng)庫有影響
第一種情況:倉(cāng)庫已刪除,并沒有類似名稱庫
[!] Unable to find a pod with name, author, summary, or description matching `YLAppTool`
[!] 找不到名稱、作者、摘要或描述與 'YLAppTool' 匹配的 pod`

第二種情況,倉(cāng)庫刪除,但是有名稱類似倉(cāng)庫
3 最重要的一點(diǎn),pod search 倉(cāng)庫會(huì)有影響
例如下面的:倉(cāng)庫屬于 [youlu-ylios repo] 倉(cāng)庫(我們的私有倉(cāng)庫),只有 [cocoapods repo] 才是屬于 cocopods 倉(cāng)庫的
- Versions: 1.2.2, 1.2.0, 1.0.1, 1.0.0 [youlu-ylios repo]
pod search 搜索,當(dāng)搜索到一個(gè)倉(cāng)庫中有之后,就不會(huì)再次出現(xiàn)同名其他倉(cāng)庫的內(nèi)容,(此處待驗(yàn)證,有大佬知道的,請(qǐng)留言,非常感謝)