1. 索引庫(kù)
cocoaPods的本地倉(cāng)庫(kù)
cd ~/.cocoapods/repos
liqun@liqundeMacBook-Pro YiQiXiuCompany % pod repo list
EqxiuRepo
- Type: git (master)
- URL: http://gitlab.yqxiu.cn/app-ios/eqxiurepo.git
- Path: /Users/liqun/.cocoapods/repos/EqxiuRepo
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/liqun/.cocoapods/repos/master
trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/liqun/.cocoapods/repos/trunk
volcengine
- Type: git (master)
- URL: https://github.com/volcengine/volcengine-specs.git
- Path: /Users/liqun/.cocoapods/repos/volcengine
4 repos

pod說(shuō)明書(shū)
找到Specs文件任意文件(索引文件),打開(kāi)如下:
名稱(chēng)、項(xiàng)目版本、描述、項(xiàng)目位置、作者、系統(tǒng)、庫(kù)tag(版本)、庫(kù)路徑、資源文件路徑等
{
"name": "CAIStatusBar",
"version": "0.0.1",
"summary": "A simple indicator",
"homepage": "https://github.com/apple5566/CAIStatusBar.git",
"license": "MIT",
"authors": {
"apple5566": "zaijiank110@sohu.com"
},
"platforms": {
"ios": "6.0"
},
"source": {
"git": "https://github.com/apple5566/CAIStatusBar.git",
"tag": "0.0.1"
},
"source_files": "CAIStatusBar/**/*.{h,m}",
"resources": "CAIStatusBar/CAIStatusBar.bundle",
"requires_arc": true
}
2. pod install
cocoaPods根據(jù)索引庫(kù)安裝,繼續(xù)以CAIStatusBar為例:
根據(jù)名稱(chēng)、tag值等索引文件信息確定安裝的Pod庫(kù)。
pod 'CAIStatusBar', '~> 0.0.1'
但如果找不到CAIStatusBar的索引文件,就會(huì)報(bào)各種錯(cuò),別著急
了解現(xiàn)在最主要的工作是要找到索引文件,索引文件可能在不同的索引庫(kù)中,剛開(kāi)始就介紹了我的本地倉(cāng)庫(kù):
一般trunk和master索引分支包含了99.99%的索引信息,所以如果存在這兩個(gè)分支,pod install按理說(shuō)一般沒(méi)問(wèn)題,其實(shí)不然,需要確定在哪個(gè)分支下下(source 源)。
liqun@liqundeMacBook-Pro YiQiXiuCompany % pod repo list
// 私有庫(kù)
EqxiuRepo
- Type: git (master)
- URL: http://gitlab.yqxiu.cn/app-ios/eqxiurepo.git
- Path: /Users/liqun/.cocoapods/repos/EqxiuRepo
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/liqun/.cocoapods/repos/master
trunk
- Type: CDN
- URL: https://cdn.cocoapods.org/
- Path: /Users/liqun/.cocoapods/repos/trunk
volcengine
- Type: git (master)
- URL: https://github.com/volcengine/volcengine-specs.git
- Path: /Users/liqun/.cocoapods/repos/volcengine
4 repos
pod install 有個(gè)小技巧,如果確定pod 索引庫(kù)在哪個(gè)分支(source)下,就只保留那個(gè)分支(source),進(jìn)行pod install,pod 庫(kù)也可以注釋分布安裝。如下:
source 'http://gitlab.yqxiu.cn/app-ios/eqxiurepo'
source 'https://cdn.cocoapods.org/'
source 'https://github.com/CocoaPods/Specs.git'
注:安裝失敗的好多時(shí)候是因?yàn)間ithub.com網(wǎng)不好,如下總是失敗,需要多次嘗試
[!] Error installing GPUImage
[!] /usr/bin/git clone https://github.com/BradLarson/GPUImage.git /var/folders/j8/3nnb0qx12v73mcgqvj36zrxc0000gn/T/d20210625-33724-7bxom1 --template= --single-branch --depth 1 --branch 0.1.7
Cloning into '/var/folders/j8/3nnb0qx12v73mcgqvj36zrxc0000gn/T/d20210625-33724-7bxom1'...
fatal: unable to access 'https://github.com/BradLarson/GPUImage.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
要點(diǎn)總結(jié):確定索引庫(kù)的存在,找到對(duì)應(yīng)源pod install。