iOS - CocoaPod重新安装 (Homebrew) 不FQ,快捷好用,中文提示。

 

最近需要重装一次。

 

检查是否有安装残留(删除CocoaPods)

如果之前装过cocopods,最好先卸载掉,卸载命令:

sudo gem uninstall cocoapods

先查看本地安装过的cocopods相关东西,命令如下:

gem list --local | grep cocoapods

会显示如下:

cocoapods-core (0.39.0)

cocoapods-downloader (0.9.3)

cocoapods-plugins (0.4.2)

cocoapods-search (0.1.0)

cocoapods-stats (0.6.2)

cocoapods-trunk (0.6.4)

cocoapods-try (0.5.1)

然后逐个删除吧:

//示例sudo gem uninstall cocoapods-core

二、使用Homebrew安装CocoaPods(无需FQ)

安装安装 Homebrew

特别提示官方的无法连接安装,可以使用下面的进行使用

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

啧啧啧,都是中文提示

出现Installation successful!提示安装成功!

接着安装ruby,继续在终端中进行

brew install ruby

安装完成后替换一下ruby源

查看ruby源gem sources -l

***CURRENT SOURCES***https://rubygems.org/

替换ruby源

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

查看是否替换成功

gem sources -l

如果出现的是https://gems.ruby-china.com/证明替换成功。

觉得好使点个赞👍

安装CocoaPods

执行下面一句

sudo gem install -n /usr/local/bin cocoapods

或 按提示操作

 brew install cocoapods
Warning: Treating cocoapods as a formula. For the cask, use homebrew/cask/cocoapods
==> Downloading https://homebrew.bintray.com/bottles/cocoapods-1.10.1.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/0caa8953926c827f62d53f9767aed0a904604c0425ea0557b24d738240db809a?respons
######################################################################## 100.0%
==> Pouring cocoapods-1.10.1.big_sur.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/xcodeproj
Target /usr/local/bin/xcodeproj
already exists. You may want to remove it:
  rm '/usr/local/bin/xcodeproj'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/xcodeproj
==> Summary
🍺  /usr/local/Cellar/cocoapods/1.10.1: 13,132 files, 30.5MB
zhuazhou005@192 me % rm '/usr/local/bin/xcodeproj'
zhuazhou005@192 me % brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.10.1... 2 symlinks created.
zhuazhou005@192 me % brew link --overwrite --dry-run cocoapods

 

其他步骤
安装cocoapods

» brew install cocoapods
检查更新

# 更新brew仓库,原理就是从github上拉去一下brew-core的最新代码
» brew update
# 检查更新
» brew outdated cocoapods
cocoapods (1.9.1) < 1.9.3
输出如上,前面是当前版本,后面是待更新版本。

更新

# 更新命令
» brew upgrade cocoapods

 



然后

pod setup

后面pod常规操作,老猿抖动 。

解决cocoapods镜像下载慢的问题

更换国内的镜像

$ cd ~/.cocoapods/repos

$ pod repo remove master

$ git clone https://gitee.com/mirrors/CocoaPods-Specs.git master (此镜像更快速,几m每秒)

也可以用清华镜像,比较慢

$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

把项目podfile里的source换:

source 'https://gitee.com/mirrors/CocoaPods-Specs.git master'

cd到项目目录: pod install

 

报错 (2022-6-23重装新mac,旧本磁盘占用过多不想数据传输)

本人后来m1新本macOS12.4通过 brew 安装工具时, 报如下错误

fatal: not in a git directory

Error: Command failed with exit 128: git

 

执行

brew doctor

 

 

 

按操作执行。

 如果还是报错从新按上面步骤安装brew ,多尝试几次,本人因为网络问题,重复3次才搞定。

MacBook-Pro ~ % pod --version 

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin21/rbconfig.rb:230: warning: Insecure world writable dir /opt/homebrew/bin in PATH, mode 040777

1.11.3

 
posted @ 2021-01-28 18:07  M·emor·Y  阅读(203)  评论(0编辑  收藏  举报