Cocoapods安装过程
1.升级Ruby环境
gem -v
gem update --system
如果没有权限去升级Ruby ?就输入
sudo gem update --system
2.换掉Ruby镜像
首先移除现有的Ruby镜像
gem sources --remove https://rubygems.org/
添加国内最新镜像源
gem source -a https://gems.ruby-china.org/
查看当前镜像
gem sources -l
3.安装CocoaPods
sudo gem install cocoapods
如果报错
sudo gem install -n /usr/local/bin cocoapods
4.初始化repos文件
pod repo add master https://github.com/CocoaPods/Specs.git
报错用这个
pod setup
5.安装过程中出现报错
报错类型1:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com
原因可能是:github.com没有被主机给解析
解决方法:在本地手动指定github.com的IP地址
编辑文件etc/hosts
sudo vi /etc/hosts
添加github的地址
::1 localhost
192.30.255.112 github.com
报错类型2:
[!] /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master --depth=1
Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Could not resolve host: github.com
原因可能是:安装多个Xcdoe,xcode路径问题
解决方法:sudo xcode-select -switch /Applications/Xcode.app/
在终端里输入下方命令可以知道Xcode的路径:
xcode-select -p
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步