正常流程
升级 RubyGems
sudo gem update --system
更换 RubyGems 镜像
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.org/
gem sources -l
安装 CocoaPods
sudo gem install cocoapods
pod setup
问题处理
报错信息与 SSL 相关的, 尝试将镜像更换为 http
gem sources --remove https://gems.ruby-china.org/
gem sources -a http://gems.ruby-china.org/
报错信息 Operation not permitted - /usr/bin/xcodeproj
尝试下面的安装命令
sudo gem install cocoapods -n /usr/local/bin
参考链接
用CocoaPods做iOS程序的依赖管理 - 唐巧
RubyGems 镜像 - Ruby China
GitHub issue: Operation not permitted - /usr/bin/xcodeproj