iOS使用cocoapods 安装libwebp 1.0.3遇到Error installing libwebp

本篇文章是转载的 ,为了防止源地址突然消失,特地搬过来的。敬上原文链接:
原文链接

可能会遇到libwebp v1.0.3超时问题:

image.png

解决方法:

尝试过翻墙,修改host,均无效
最终,修改pod repolibwebpgit source 地址,再执行pod install 解决,
但是我们需要有一个有效的libwebp的git仓库,在github上找到了一个https://github.com/webmproject/libwebp.git,可以看到 mirrored from https://chromium.googlesource.com/webm/libwebp,而且正好有我需要的版本1.0.3, 那么我就替换为这个。

下面是步骤:

1.查看maccocoapods本地库路径:

swaedeMacBook-Pro:alpface swae$ pod repo

2.在本地库中, 并找到对应的libwebp版本的文件

swaedeMacBook-Pro:alpface swae$ find ~/.cocoapods/repos/master -iname libwebp



/Users/swae/.cocoapods/repos/master/Specs/1/9/2/libwebp

进入libwebp目录,可以看到你的仓库中有哪些对应的版本

swaedeMacBook-Pro:libwebp swae$ cd ~/.cocoapods/repos/master/Specs/1/9/2/libwebp
swaedeMacBook-Pro:libwebp swae$ ls -l
total 0
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.4.1
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.4.2
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.4.3
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.4.4
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.5.0
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.5.1
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 0.5.2
drwxr-xr-x  4 cct  staff  128 Sep 12  2019 0.6.0
drwxr-xr-x  3 cct  staff   96 Jun  4  2019 0.6.1
drwxr-xr-x  3 cct  staff   96 Aug 13  2018 1.0.0
drwxr-xr-x  3 cct  staff   96 Mar  8  2019 1.0.1
drwxr-xr-x  3 cct  staff   96 Mar 14 17:00 1.0.2
drwxr-xr-x  4 cct  staff  128 Mar 14 17:00 1.0.3
drwxr-xr-x  3 cct  staff   96 Mar 14 17:00 1.1.0
drwxr-xr-x  3 cct  staff   96 Jan  4 10:59 1.1.0-rc2

由于SDWebImage 依赖的 libwebp版本为1.0.3,所以我们进入1.0.3中,并做修改

swaedeMacBook-Pro:libwebp swae$ cd 1.0.3/
swaedeMacBook-Pro:0.6.0 swae$ ls -l
total 8
-rw-r--r--@ 1 swae  staff  1587  4 15 09:53 libwebp.podspec.json

1.0.3目录下的libwebp.podspec.json文件中修改git source(点击i进入INSERT 编辑模式)

swaedeMacBook-Pro:1.0.3 swae$ sudo vim libwebp.podspec.json
{
  "name": "libwebp",
  "version": "1.0.3",
  "summary": "Library to encode and decode images in WebP format.",
  "homepage": "https://developers.google.com/speed/webp/",
  "authors": "Google Inc.",
  "license": {
    "type": "BSD",
    "file": "COPYING"
  },
  "source": {
    "git": "https://chromium.googlesource.com/webm/libwebp",
    "tag": "v1.0.3"
  },
  "compiler_flags": "-D_THREAD_SAFE",
  "requires_arc": false,
  "platforms": {
    "osx": "10.8",
    "ios": "6.0",
    "tvos": "9.0",
    "watchos": "2.0"
  },
-- INSERT --

找到下面代码

  "source": {
    "git": "https://chromium.googlesource.com/webm/libwebp",
    "tag": "v1.0.3"
  },

将其中的"git"对应的url替换为https://github.com/webmproject/libwebp.git,并保存 (点击ESC退出编辑模式,然后输入 :wq) ,过程有点漫长,请耐心等待

最后再进入对应的项目中,重新执行pod install, 成功

swaedeMacBook-Pro:alpface swae$ pod install

你可能感兴趣的:(iOS使用cocoapods 安装libwebp 1.0.3遇到Error installing libwebp)