开发集锦

x86 & M1 重装 cocoaspod

2022-02-26  本文已影响0人  读书有毒不中毒

==================. x86 ====================
最近需要重装一次。

检查是否有安装残留(删除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(无需翻墙)

1.安装安装 Homebrew

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

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

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

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

brew install ruby

3.安装完成后替换一下ruby源

查看ruby源gem sources -l

CURRENT SOURCEShttps://rubygems.org/

替换ruby源

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

4.查看是否替换成功

gem sources -l

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

5.安装CocoaPods

执行下面一句

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

===========M1 作为参考 ==============
参考 http://events.jianshu.io/p/3ee9133c7011

一、使用Homebrew安装CocoaPods(无需翻墙)
1.更改终端的配置,找到终端简介,勾选Rosetta

2.安装安装 Homebrew

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

2.1报错

Error running '__rvm_make install',
please read /Users/mac/.rvm/log/1655699107/openssl_make.install.log

2.1解决

rvm reinstall all --force

报错

Error running 'env GEM_HOME=/Users/mac/.rvm/gems/ruby-2.6.3@global GEM_PATH= /Users/mac/.rvm/rubies/ruby-2.6.3/bin/ruby -d /Users/mac/.rvm/src/rubygems-3.0.9/setup.rb --no-document',
please read /Users/mac/.rvm/log/1655699335_ruby-2.6.3/rubygems.install.log

解决

rvm remove ruby-2.6.3
rvm get head --autolibs=3
rvm requirements
rvm install ruby-2.6.3
rvm --default use ruby-2.6.3

3.更换源

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

报错

fatal: not in a git directory
Error: Command failed with exit 128: git

输入

brew -v

3.安装 cocoapods

sudo gem install cocoapods

执行 pod setup 出现 setup completed

pod setup

4.创建文件夹.cocoapods 和repos,创建.cocoapods时,需要打开显示隐藏文件夹cms+shift+.快捷键,然后创建

5.设置repos文件夹Git初始化,即,在repos文件路径下

pod repo remove master
cd ~/.cocoapods/repos 
git init
git clone --depth 1 https://github.com/CocoaPods/Specs.git master
rm ~/Library/Caches/CocoaPods/search_index.json
pod search AFNetWorking
上一篇 下一篇

猜你喜欢

热点阅读