Mac CocoaPods 安装

pwf00 2019-06-25

CocoaPods 环境

CocoaPods是使用Ruby语言写的,所以需要Ruby的支持,mac自带Ruby

由于操作系统的安全问题,苹果禁止升级系统的Ruby,其实也没有这个必要,只要是系统版本比较新的,自带的软件版本都会比较新。

如果非要用最新版本的Ruby,可用通过Homebrew安装另外一个Ruby,这样就不会和系统的有冲突了。

CocoaPods is built with Ruby and is installable with the default Ruby available on OS X. We recommend you use the default Ruby.

Using the default Ruby install can require you to use sudo when installing gems. Further installation instructions are in the guides.

修改 gem 镜像

阿里云 Rubygems 开源镜像

gem source -r https://rubygems.org/
gem source -a http://mirrors.aliyun.com/rubygems/

安装CocoaPods

# Xcode 8 + 9
$ sudo gem install cocoapods //有的版本的系统不需要sudo权限

修改 CocoaPods 镜像

这里我使用清华大学开源软件镜像站,以下是该镜像站的使用说明

清华大学开源 CocoaPods 镜像使用帮助

$ cd ~/.cocoapods/repos 
$ pod repo remove master
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master

最后进入自己的工程,在自己工程的podFile第一行加上:

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

CocoaPods APP

听说 CocoaPods 有个APP,不想折腾了,不知道能不能修改索引,改成国内的镜像,这样就少折腾点

不过这不是正常的路啊!

相关推荐