1.在终端查看Cocoapods依赖的语言环境
macdeiMac-43:~ mac$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
2.列出gem命令管理工具的【源】的服务器列表
macdeiMac-43:~ mac$ gem source -l
*** CURRENT SOURCES ***
https://rubygems.org/
3.删除现有的源服务器的地址换为淘宝的,(中国的墙GFW的原因)
macdeiMac-43:~ mac$ gem source -r https://rubygems.org/
https://rubygems.org/ removed from sources
macdeiMac-43:~ mac$ gem source -l
*** CURRENT SOURCES ***
macdeiMac-43:~ mac$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
macdeiMac-43:~ mac$ gem source -l
*** CURRENT SOURCES ***
https://ruby.taobao.org/
4.安装cocoapods工具,安装时时间稍微有点长
macdeiMac-43:~ mac$sudo gem install cocoapods
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
此处的密码是你的开机密码,输入时是看不见的
Password:
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: minitest-5.8.4.gem (100%)
Successfully installed minitest-5.8.4
Fetching: activesupport-4.2.5.1.gem (100%)
Successfully installed activesupport-4.2.5.1
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-0.39.0.gem (100%)
Successfully installed cocoapods-core-0.39.0
Fetching: claide-0.9.1.gem (100%)
Successfully installed claide-0.9.1
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: xcodeproj-0.28.2.gem (100%)
Successfully installed xcodeproj-0.28.2
Fetching: cocoapods-downloader-0.9.3.gem (100%)
Successfully installed cocoapods-downloader-0.9.3
Fetching: cocoapods-plugins-0.4.2.gem (100%)
Successfully installed cocoapods-plugins-0.4.2
Fetching: cocoapods-search-0.1.0.gem (100%)
Successfully installed cocoapods-search-0.1.0
Fetching: cocoapods-stats-0.6.2.gem (100%)
Successfully installed cocoapods-stats-0.6.2
Fetching: cocoapods-try-0.5.1.gem (100%)
Successfully installed cocoapods-try-0.5.1
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-0.6.4.gem (100%)
Successfully installed cocoapods-trunk-0.6.4
Fetching: molinillo-0.4.2.gem (100%)
Successfully installed molinillo-0.4.2
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: cocoapods-0.39.0.gem (100%)
Successfully installed cocoapods-0.39.0
Parsing documentation for i18n-0.7.0
Installing ri documentation for i18n-0.7.0
Parsing documentation for thread_safe-0.3.5
Installing ri documentation for thread_safe-0.3.5
Parsing documentation for tzinfo-1.2.2
Installing ri documentation for tzinfo-1.2.2
Parsing documentation for minitest-5.8.4
Installing ri documentation for minitest-5.8.4
Parsing documentation for activesupport-4.2.5.1
unable to convert "\x84" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping
Installing ri documentation for activesupport-4.2.5.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-0.39.0
Installing ri documentation for cocoapods-core-0.39.0
Parsing documentation for claide-0.9.1
Installing ri documentation for claide-0.9.1
Parsing documentation for colored-1.2
Installing ri documentation for colored-1.2
Parsing documentation for xcodeproj-0.28.2
Installing ri documentation for xcodeproj-0.28.2
Parsing documentation for cocoapods-downloader-0.9.3
Installing ri documentation for cocoapods-downloader-0.9.3
Parsing documentation for cocoapods-plugins-0.4.2
Installing ri documentation for cocoapods-plugins-0.4.2
Parsing documentation for cocoapods-search-0.1.0
Installing ri documentation for cocoapods-search-0.1.0
Parsing documentation for cocoapods-stats-0.6.2
Installing ri documentation for cocoapods-stats-0.6.2
Parsing documentation for cocoapods-try-0.5.1
Installing ri documentation for cocoapods-try-0.5.1
Parsing documentation for netrc-0.7.8
Installing ri documentation for netrc-0.7.8
Parsing documentation for cocoapods-trunk-0.6.4
Installing ri documentation for cocoapods-trunk-0.6.4
Parsing documentation for molinillo-0.4.2
Installing ri documentation for molinillo-0.4.2
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
21 gems installed
5.查看pod的使用帮助
macdeiMac-43:~ mac$ pod
Usage:
$podCOMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ cacheManipulate the CocoaPods cache
+ initGenerate a Podfile for the current directory.
+ installInstall project dependencies to Podfile.lock versions
+ ipcInter-process communication
+ libDevelop pods
+ listList pods
+ outdatedShow outdated project dependencies
+ pluginsShow available CocoaPods plugins
+ repoManage spec-repositories
+ searchSearch for pods.
+ setupSetup the CocoaPods environment
+ specManage pod specs
+ trunkInteract with the CocoaPods API (e.g. publishing new specs)
+ tryTry a Pod!
+ updateUpdate outdated project dependencies and create new
Podfile.lock
Options:
--silentShow nothing
--versionShow the version of the tool
--verboseShow more debugging information
--no-ansiShow output without ANSI codes
--helpShow help banner of specified command
macdeiMac-43:~ mac$
6.使用步骤:
(1).在现有工程里面加入cocoapods管理
打开终端,cd到工程路径下
(2).执行pod init命令,初始化生成Podfile
(3).使用终端搜索三方库:
pod search AFNet
(4).在Podfile中编辑,添加所需的三方库
pod 'AFNetworking', '~> 3.0.4'
(5).使用终端执行
安装三方库pod install
升级三方库pod update
以后Podfile中有需要修改添加新的就重复执行
步骤3 ~步骤5
Updating local specs repositories
更新速度比较慢,更新时间比较长
可以使用pod update --no-repo-update来解决