CocoaPods是什么夸浅?
當(dāng)你開發(fā)iOS應(yīng)用時(shí),會(huì)經(jīng)常使用到很多第三方開源類庫扔役,比如JSONKit帆喇,AFNetWorking等等∫谛兀可能某個(gè)類庫又用到其他類庫坯钦,所以要使用它,必須得另外下載其他類庫侈玄,而其他類庫又用到其他類庫婉刀,“子子孫孫無窮盡也”,這也許是比較特殊的情況序仙⊥患眨總之小編的意思就是,手動(dòng)一個(gè)個(gè)去下載所需類庫十分麻煩潘悼。另外一種常見情況是律秃,你項(xiàng)目中用到的類庫有更新,你必須得重新下載新版本治唤,重新加入到項(xiàng)目中棒动,十分麻煩。如果能有什么工具能解決這些惱人的問題宾添,那將“善莫大焉”船惨。所以,你需要 CocoaPods缕陕。
CocoaPods應(yīng)該是iOS最常用最有名的類庫管理工具了粱锐,上述兩個(gè)煩人的問題,通過cocoaPods扛邑,只需要一行命令就可以完全解決卜范,當(dāng)然前提是你必須正確設(shè)置它。重要的是鹿榜,絕大部分有名的開源類庫海雪,都支持CocoaPods。所以舱殿,作為iOS程序員的我們奥裸,掌握CocoaPods的使用是必不可少的基本技能了。
如何下載和安裝CocoaPods沪袭?
在安裝CocoaPods之前湾宙,首先要在本地安裝好Ruby環(huán)境樟氢。至于如何在Mac中安裝好Ruby環(huán)境.Ruby 是一種面向?qū)ο?/a>、命令式侠鳄、函數(shù)式埠啃、動(dòng)態(tài)的通用編程語言。
著名的github 和twitter 網(wǎng)站就是ruby開發(fā)而成伟恶!
安裝ruby環(huán)境之前需要安裝 RVM
rvm是啥東西是啥東西(搞得好復(fù)雜的樣子 不要慌 喝口茶慢慢看)~
一句話:RVM 是一個(gè)命令行工具碴开,可以提供一個(gè)便捷的多版本 Ruby 環(huán)境的管理和切換。
https://rvm.io/
打開你們的終端
輸入:
$ curl -L https://get.rvm.io | bash -s stable
小白們** $**是終端有的符號(hào) 不必打進(jìn)去
會(huì)出現(xiàn)如下信息證明安裝成功了
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 86 0 0:00:02 0:00:02 --:--:-- 86
100 22721 100 22721 0 0 7170 0 0:00:03 0:00:03 --:--:-- 43862
Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Installing RVM to /Users//.rvm/
Adding rvm PATH line to /Users//.profile /Users//.mkshrc /Users//.bashrc /Users//.zshrc.
Adding rvm loading line to /Users//.profile /Users//.bash_profile /Users//.zlogin.
Installation of RVM in /Users//.rvm/ is almost complete:
- To start using RVM you need to run
source /Users//.rvm/scripts/rvm
in all your open shell windows, in rare cases you need to reopen all shell windows.
ppbrunt,
Thank you for using RVM!
We sincerely hope that RVM helps to make your life easier and more enjoyable!!! ~Wayne, Michal & team.
In case of problems: http://rvm.io/help and https://twitter.com/rvm_i
如果對Ruby感興趣可以安裝rails 框架~~
由于在國內(nèi)墻的關(guān)系 你需要把網(wǎng)站換成 淘寶鏡像服務(wù)器
輸入如下命令(空格打多了 = 博秫。=)
$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
查看
$ gem sources -l
出現(xiàn)如下信息
*** CURRENT SOURCES ***
https://ruby.taobao.org#
請確保只有 ruby.taobao.org
安裝Ruby
$ rvm install 2.0.0
設(shè)置默認(rèn)版本
$ rvm 2.0.0 --default
查詢已經(jīng)安裝的ruby
$ rvm list
安裝 cocoapods
sudo gem install cocoapods
等上十幾秒鐘潦牛,CocoaPods就可以在你本地下載并且安裝好了,不再需要其他設(shè)置挡育。