CocoaPods 默态框架下载失败及过慢的解决方案

Author Avatar
Fa1c0n 3月 01, 2017
  • 在其它设备中阅读本文章

在刚刚安装好CocoaPods后,为项目配置框架时,执行pod install会出现如下问题:

sh-3.2# pod install
Updating local specs repositories
Analyzing dependencies
[!] Unable to find a specification for `SDWebImage`

即为:错误:[!] Unable to find a specification for ‘$randomFrameworkName’
$randomFrameworkName可替换为任意框架名称,如SDWebImage。

经研究,得出解决方案为:更换CocoaPods的默认pod-repolist

更换repolist-spec镜像方案:
spec镜像方案源链接

pod repo remove master
pod repo add master https://gitcafe.com/akuandev/Specs.git
pod repo update

如果想用oschina的镜像也可以把第二条命令 换成 http://git.oschina.net/akuandev/Specs.git 即可


更换操作记录如下:

sh-3.2# pod repo list
master
- Type: git (master)
- URL:      https://github.com/CocoaPods/Specs.git
- Path: /Users/Fa1c0n/.cocoapods/repos/master
1 repo

sh-3.2# pod repo remove master
Removing spec repo `master`

sh-3.2# pod repo add master https://gitcafe.com/akuandev/Specs.git
Cloning spec repo `master` from `https://gitcafe.com/akuandev/Specs.git`

sh-3.2# pod repo update
Updating spec repo `master`
Already up-to-date.

sh-3.2# pod install

Creating shallow clone of spec repo `master-1` from `https://github.com/CocoaPods/Specs.git`
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.0)
Installing AFOnoResponseSerializer (1.0.0)
Installing DateTools (1.7.0)
Installing GPUImage (0.1.7)
Installing GRMustache (7.3.2)
Installing JRSwizzle (1.0)
Installing MBProgressHUD (0.9.1)
Installing MJRefresh (2.4.12)
Installing Ono (1.2.2)
Installing RESideMenu (4.0.7)
Installing Reachability (3.2)
Installing ReactiveCocoa (2.5)
Installing SDWebImage (3.7.3)
Installing SSKeychain (1.2.3)
Installing TBXML (1.5)
Installing TOWebViewController (2.0.19)
Installing TTTAttributedLabel (1.13.4)
Generating Pods project
Integrating client project
Pod installation complete! There are 14 dependencies from the Podfile and 17 total pods installed.

在执行pod install和pod update过程中,由于CocoaPods会自动升级spec库,导致执行过程缓慢,可使用以下参数忽略升级spec库:

pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

由于pod版本更新,会导致重复克隆pod文件,解决方案:在Podfile的第一行中加入:

source ‘https://gitcafe.com/akuandev/Specs.git‘

即可解决