前言,鑒於很多人都比較趕時間,有人是為了去應付工作,有人是為了去找妹子,總之,不管你懂不懂,如果你只是想安裝一下,那麼你只需要按照濤叔下面畫黃色的命令複製粘貼到終端順序執行就好了。
一、安裝
1、Ruby环境搭建
1.1查看下当前ruby版本:打开终端输入 ruby -v
$ ruby -v
libotaodeMacBook-Pro:~ libotao$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
1.2更新ruby (濤叔在此並沒有更新,如果後續安裝工作失敗,請執行下列更新命令。)跟新方法如下
#查看当前ruby版本
$ ruby -v
ruby 1.8.7
#列出已知的ruby版本
$ rvm list known
#安装ruby 1.9.3
$ rvm install 1.9.3
2. 安裝cocoapods
通过淘宝的镜像来访问cocoapods 在天朝,由于cocoapods.org被墙,我们可以使用淘宝的ruby镜像来访问
sudo gem sources -a http://ruby.taobao.org/
libotaodeMacBook-Pro:~ libotao$ sudo gem sources -a http://ruby.taobao.org/
Password:
http://ruby.taobao.org/ added to sources
sudo gem sources -r https://rubygems.org/
libotaodeMacBook-Pro:~ libotao$ sudo gem sources -r https://rubygems.org/
Password:
https://rubygems.org/ removed from sources
gem sources –l (用该命令查看ruby镜像是否是taobao)
libotaodeMacBook-Pro:~ libotao$ gem sources –l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
sudo gem install cocoapods
libotaodeMacBook-Pro:~ libotao$ sudo gem install cocoapods
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.6.0.gem (100%)
Successfully installed minitest-5.6.0
Fetching: activesupport-4.2.1.gem (100%)
Successfully installed activesupport-4.2.1
Fetching: nap-0.8.0.gem (100%)
Successfully installed nap-0.8.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-0.36.4.gem (100%)
Successfully installed cocoapods-core-0.36.4
Fetching: claide-0.8.1.gem (100%)
Successfully installed claide-0.8.1
Fetching: colored-1.2.gem (100%)
Successfully installed colored-1.2
Fetching: xcodeproj-0.23.1.gem (100%)
Successfully installed xcodeproj-0.23.1
Fetching: cocoapods-downloader-0.9.0.gem (100%)
Successfully installed cocoapods-downloader-0.9.0
Fetching: cocoapods-plugins-0.4.2.gem (100%)
Successfully installed cocoapods-plugins-0.4.2
Fetching: cocoapods-try-0.4.3.gem (100%)
Successfully installed cocoapods-try-0.4.3
Fetching: netrc-0.7.8.gem (100%)
Successfully installed netrc-0.7.8
Fetching: cocoapods-trunk-0.6.0.gem (100%)
Successfully installed cocoapods-trunk-0.6.0
Fetching: molinillo-0.2.3.gem (100%)
Successfully installed molinillo-0.2.3
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: open4-1.3.4.gem (100%)
Successfully installed open4-1.3.4
Fetching: cocoapods-0.36.4.gem (100%)
Successfully installed cocoapods-0.36.4
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.6.0
Installing ri documentation for minitest-5.6.0
Parsing documentation for activesupport-4.2.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.1
Parsing documentation for nap-0.8.0
Installing ri documentation for nap-0.8.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-0.36.4
Installing ri documentation for cocoapods-core-0.36.4
Parsing documentation for claide-0.8.1
Installing ri documentation for claide-0.8.1
Parsing documentation for colored-1.2
Installing ri documentation for colored-1.2
Parsing documentation for xcodeproj-0.23.1
Installing ri documentation for xcodeproj-0.23.1
Parsing documentation for cocoapods-downloader-0.9.0
Installing ri documentation for cocoapods-downloader-0.9.0
Parsing documentation for cocoapods-plugins-0.4.2
Installing ri documentation for cocoapods-plugins-0.4.2
Parsing documentation for cocoapods-try-0.4.3
Installing ri documentation for cocoapods-try-0.4.3
Parsing documentation for netrc-0.7.8
Installing ri documentation for netrc-0.7.8
Parsing documentation for cocoapods-trunk-0.6.0
Installing ri documentation for cocoapods-trunk-0.6.0
Parsing documentation for molinillo-0.2.3
Installing ri documentation for molinillo-0.2.3
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for open4-1.3.4
Installing ri documentation for open4-1.3.4
Parsing documentation for cocoapods-0.36.4
Installing ri documentation for cocoapods-0.36.4
20 gems installed
設置:將第三方框架在本地進行一些設置
$pod setup
pod setup命令执行后原理是将Spec项目复制到当前用户的.cocoapods\master目录下,以后的查找、安装使用都是基于该本地目录的.
安装成功后,就可以尝试使用了,以后更新新版本的Spec项目只需要再次执行pod setup即可
libotaodeMacBook-Pro:~ libotao$ pod setup
Setting up CocoaPods master repo
Setup completed
关于Spec
简单的说,Spec就是每个包在CocoaPods中的配置文件,其中包括Package的名字,版本号,每个版本对应的下载地址,编译时的参数等等。
这是该项目的地址:https://github.com/CocoaPods/Specs
在页面上有介绍如何创新新的包,可以Fork该项目,然后通过pull request提交所建的新包。
附上一篇详细的教程
http://ishalou.com/blog/2012/10/16/how-to-create-a-cocoapods-spec-file/
二、查看你是否安裝成功
$pod
libotaodeMacBook-Pro:~ libotao$ pod
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ init Generate a Podfile for the current directory.
+ install Install project dependencies to Podfile.lock versions
+ ipc Inter-process communication
+ lib Develop pods
+ list List pods
+ outdated Show outdated project dependencies
+ plugins Show available CocoaPods plugins
+ repo Manage spec-repositories
+ search Searches for pods
+ setup Setup the CocoaPods environment
+ spec Manage pod specs
+ trunk Interact with the CocoaPods API (e.g. publishing new specs)
+ try Try a Pod!
+ update Update outdated project dependencies and create new
Podfile.lock
Options:
--silent Show nothing
--version Show the version of the tool
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command
三、安裝插件
curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh
github 地址:https://github.com/supermarin/Alcatraz
或者下載Alcatraz 直接用XCode運行即可安裝。在這裡可以管理第三方插件。在下面搜CocoaPods并安裝可以省卻命令行操作。