首先我的Mac系统是OS X EI
先安装cocoa pods
1.更换环境
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
2.输入
gem sources -l
显示*** CURRENT SOURCES ***
https://ruby.taobao.org/
3.mac OS X EI 要输入sudo gem install -n /usr/local/bin cocoapods
4.pod setup出现如下错误
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
这时要输入sudo xcode-select --switch /Applications/Xcode.app
之后再输入pod setup
这时会显示
Setting up CocoaPods master repo
Setup completed
开始使用cocoa pods
以iCarousel为例
1.查找iCarousel的版本pod search iCarousel
2.新建工程,cd到自己的工程里cd /Users/shenlulu/Documents/cocoapodsTest(输完cd后找到文件直接拖过来)
3.vim Podfile
在Pod file里面输入
platform :ios
target "cocoapodsTest" do
pod 'iCarousel', '~> 1.8.2'
end
保存退出
4.pod install
显示如下
Analyzing dependencies
Downloading dependencies
Installing iCarousel (1.8.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `cocoapodsTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.