Macbook 项目 pod update 无法更新的解决方法
程序员文章站
2024-03-18 09:50:58
...
一、pod update 更新失败
Mac book 中 swift 使用 CocoaPods 管理插件一直正常,但最近用 pod update 时不能更新,出现错误信息
wiukings-MacBook-Pro:JloudOevel wiuking$ pod update --repo-update
Update all pods
Updating local specs repositories
Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/wiuking/.cocoapods/repos` or via `pod repo add`.
提示要手动添加源 https://github.com/CocoaPods/Specs.git,但我的 profile 文件中己存在。经过努力后通过下列步骤解决了这一问题。
二、解决方法
1.通过ipaddress.com查询github.com域名对应的IP.
点击上图红色区域
分别点击上图红色区域
记下 github.com 的 ip 地址 140.82.112.4
再记下 github.global.ssl.fastly.net 的 ip 地址 192.232.69.194
2.把上面记下的 ip 地址加入 etc/hosts 文件尾部
wiuking-MacBook-Pro:~ wiuking$ sudo vi /etc/hosts
3.在终端执行下列命令
wiukings-MacBook-Pro:JloudOevel wiuking$ cd ~/.cocoapods/repos
wiukings-MacBook-Pro:repos wiuking$ git config --global http.postBuffer 524288000
wiukings-MacBook-Pro:repos wiuking$ git clone --depth 1 https://github.com/CocoaPods/Specs.git master
输出如下
Cloning into 'master'...
remote: Enumerating objects: 915959, done.
remote: Counting objects: 100% (915959/915959), done.
remote: Compressing objects: 100% (557340/557340), done.
remote: Total 915959 (delta 235489), reused 879204 (delta 232044), pack-reused
Receiving objects: 100% (915959/915959), 135.18 MiB | 207.00 KiB/s, done.
Resolving deltas: 100% (235489/235489), done.
Checking connectivity: 915959, done.
Updating files: 100% (420300/420300), done.
wiukings-MacBook-Pro:repos wiuking$
4.最后执行下列命令
wiukings-MacBook-Pro:repos wiuking$ cd ~/Documents/swift/JloudOevel
wiukings-MacBook-Pro:JloudOevel wiuking$ pod update --repo-update
JloudOevel 是我的项目目录,你要替换成你自己的项目目录。执行成功输出如下
Update all pods
Updating local specs repositories
$ /usr/bin/git -C /Users/wiuking/.cocoapods/repos/master fetch origin
--progress
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 9 (delta 6), reused 0 (delta 0), pack-reused 0
From https://github.com/CocoaPods/Specs
d14b591770..cdab53146e master -> origin/master
$ /usr/bin/git -C /Users/wiuking/.cocoapods/repos/master rev-parse
--abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/wiuking/.cocoapods/repos/master reset --hard
origin/master
HEAD is now at cdab53146e [Add] NativoSDK 5.2.1
Analyzing dependencies
Downloading dependencies
Installing Google-Mobile-Ads-SDK (7.60.0)
Installing GoogleAppMeasurement (6.6.0)
Installing GoogleUtilities (6.6.0)
Installing PromisesObjC (1.2.9)
Installing RxCocoa (5.1.1)
Installing RxRelay (5.1.1)
Installing RxSwift (5.1.1)
Installing nanopb (1.30905.0)
Generating Pods project
Integrating client project
Pod installation complete! There are 3 dependencies from the Podfile and 8 total pods installed.
至此成功解决了pod update 的更新问题。