iOS 最新版 CocoaPods 的安装流程
1.移除现有Ruby默认源
$gem sources --remove https://rubygems.org/
2.使用新的源
$gem sources -a https://ruby.taobao.org/
3.验证新源是否替换成功
$gem sources -l
4.安装CocoaPods
(1) $sudo gem install cocoapods 备注:苹果系统升级 OS X EL Capitan 后改为 $sudo gem install -n /usr/local/bin cocoapods
(2) $pod setup
5.更新gem
$sudo gem update --system
6. 新建工程,并在终端用cd指令到文件夹内
$pod search 第三方
7.新建文件 vim “Podfile”,
$vim Podfile
写入以下内容并保存 小提示:(终端vim文件 按 i 可编辑 ,esc 退出编辑,:wq 可保存退出)
platform:ios, '6.0'
pod 'AFNetworking', '~> 2.3.1' <-------第三方
8.导入第三方库
$pod install
9.退出终端
第一次失败
$ pod install
Creating shallow clone of spec repo `master` from `https://github.com/CocoaPods/Specs.git`
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
$ pod install
第二次成功
pod install
Creating shallow clone of spec repo `master` from `https://github.com/CocoaPods/Specs.git`
CocoaPods 1.0.0.beta.6 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Updating local specs repositories
CocoaPods 1.0.0.beta.6 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.5.4)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `test.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
更根提醒进行更新
$ gem install cocoapods --pre
Fetching: cocoapods-core-1.0.0.beta.4.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
tianxiaochundeMacBook-Pro:test ihsdwj$ sudo gem install cocoapods --pre
Password:
Fetching: cocoapods-core-1.0.0.beta.4.gem (100%)
Successfully installed cocoapods-core-1.0.0.beta.4
Fetching: claide-1.0.0.beta.1.gem (100%)
Successfully installed claide-1.0.0.beta.1
Fetching: cocoapods-deintegrate-1.0.0.beta.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.0.beta.1
Fetching: cocoapods-downloader-1.0.0.beta.1.gem (100%)
Successfully installed cocoapods-downloader-1.0.0.beta.1
Fetching: cocoapods-plugins-1.0.0.beta.1.gem (100%)
Successfully installed cocoapods-plugins-1.0.0.beta.1
Fetching: cocoapods-search-1.0.0.beta.1.gem (100%)
Successfully installed cocoapods-search-1.0.0.beta.1
Fetching: cocoapods-stats-1.0.0.beta.3.gem (100%)
Successfully installed cocoapods-stats-1.0.0.beta.3
Fetching: cocoapods-trunk-1.0.0.beta.2.gem (100%)
Successfully installed cocoapods-trunk-1.0.0.beta.2
Fetching: cocoapods-try-1.0.0.beta.2.gem (100%)
Successfully installed cocoapods-try-1.0.0.beta.2
Fetching: xcodeproj-1.0.0.beta.3.gem (100%)
Successfully installed xcodeproj-1.0.0.beta.3
Fetching: fourflusher-0.3.0.gem (100%)
Successfully installed fourflusher-0.3.0
Fetching: cocoapods-1.0.0.beta.4.gem (100%)
Successfully installed cocoapods-1.0.0.beta.4
Parsing documentation for cocoapods-core-1.0.0.beta.4
Installing ri documentation for cocoapods-core-1.0.0.beta.4
Parsing documentation for claide-1.0.0.beta.1
Installing ri documentation for claide-1.0.0.beta.1
Parsing documentation for cocoapods-deintegrate-1.0.0.beta.1
Installing ri documentation for cocoapods-deintegrate-1.0.0.beta.1
Parsing documentation for cocoapods-downloader-1.0.0.beta.1
Installing ri documentation for cocoapods-downloader-1.0.0.beta.1
Parsing documentation for cocoapods-plugins-1.0.0.beta.1
Installing ri documentation for cocoapods-plugins-1.0.0.beta.1
Parsing documentation for cocoapods-search-1.0.0.beta.1
Installing ri documentation for cocoapods-search-1.0.0.beta.1
Parsing documentation for cocoapods-stats-1.0.0.beta.3
Installing ri documentation for cocoapods-stats-1.0.0.beta.3
Parsing documentation for cocoapods-trunk-1.0.0.beta.2
Installing ri documentation for cocoapods-trunk-1.0.0.beta.2
Parsing documentation for cocoapods-try-1.0.0.beta.2
Installing ri documentation for cocoapods-try-1.0.0.beta.2
Parsing documentation for xcodeproj-1.0.0.beta.3
Installing ri documentation for xcodeproj-1.0.0.beta.3
Parsing documentation for fourflusher-0.3.0
Installing ri documentation for fourflusher-0.3.0
Parsing documentation for cocoapods-1.0.0.beta.4
Installing ri documentation for cocoapods-1.0.0.beta.4
12 gems installed