默认情况下,Mac 是自带了 Ruby 环境的,可以通过命令行 ruby -v
查看当前Ruby的版本。
$ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
接下来是安装 CocoaPods
$ sudo gem install cocoapods
$ gem install cocoapods
如果出错
$ gem sources -a http://rubygems-china.oss.aliyuncs.com
再次执行命令:sudo gem install cocoapods
,成功后的效果如下
$ sudo gem install cocoapods Fetching: cocoapods-core-0.37.1.gem (100%) Successfully installed cocoapods-core-0.37.1 Fetching: cocoapods-try-0.4.4.gem (100%) Successfully installed cocoapods-try-0.4.4 Fetching: cocoapods-0.37.1.gem (100%) Successfully installed cocoapods-0.37.1 Parsing documentation for cocoapods-core-0.37.1 Installing ri documentation for cocoapods-core-0.37.1 Parsing documentation for cocoapods-try-0.4.4 Installing ri documentation for cocoapods-try-0.4.4 Parsing documentation for cocoapods-0.37.1 Installing ri documentation for cocoapods-0.37.1 3 gems installed
cd 到当前工程的路径下,然后创建Podfile文件 $ touch Podfile,
vim Podfile 编辑Podfile文件
platform :ios, '9.0' pod 'SDWebImage', '~> 4.0'
退出编辑, :wq
pod install 安装