iOS開發~CocoaPods使用詳細說明

來源:互聯網
上載者:User

一、概要

iOS開發時,項目中會引用許多第三方庫,CocoaPods(https://github.com/CocoaPods/CocoaPods)可以用來方便的統一管理這些第三方庫(從一個坑出來,又進了另一個坑而已……)。


二、安裝

由於網上的教程基本都大同小異,但細節之處還不是很完善,所以藉機會在這裡補充下:

註:要使用CocoaPods,那就要下載安裝它,而下載安裝CocoaPods需要Ruby環境


1、Ruby環境搭建

當前安裝環境為Mac mini 10.8.5。Mac  OS本身內建Ruby,但還是更新一下保險,因為我第一次安裝在沒有更新Ruby的情況下就失敗了。

a 查看下當前ruby版本:開啟終端輸入 ruby -v(確實安裝了,不過用這個版本接下來工作失敗了,所以更新下ruby)

[objc]  view plain  copy  print ? ritekiMac-mini:PodTest lucky$ ruby -v   ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]   ritekiMac-mini:PodTest lucky$   
b 更新ruby

終端輸入如下命令(把Ruby鏡像指向taobao,避免被牆,你懂得)

gem sources --remove https://rubygems.org/ 
gem sources -a http://ruby.taobao.org/ 
gem sources -l  (用來檢查使用替換鏡像位置成功)

[objc]  view plain  copy  print ? ritekiMac-mini:~ lucky$ gem sources --remove https://rubygems.org/   https://rubygems.org/ removed from sources   ritekiMac-mini:~ lucky$ gem sources -a http://ruby.taobao.org/   http://ruby.taobao.org/ added to sources   ritekiMac-mini:~ lucky$ gem sources -l   *** CURRENT SOURCES ***  

補充:(2016-01-20更新)

淘寶已經關閉HTTP協議的景象服務,改為HTTPS協議。

淘寶ruby地址:https://ruby.taobao.org/ 2、下載安裝 CocoaPods

終端輸入:sudo gem install cocoapods 


[html]  view plain  copy  print ? ritekiMac-mini:~ lucky$ sudo gem install cocoapods      CHANGELOG:      ## 0.32.1      ##### Bug Fixes      * Fixed the Podfile `default_subspec` attribute in nested subspecs.       [Fabio Pelosin][irrationalfab]    \ [#2050](https://github.com/CocoaPods/CocoaPods/issues/2050)         Successfully installed cocoapods-0.32.1   Installing ri documentation for cocoapods-0.32.1   /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block   /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block   Done installing documentation for cocoapods after 10 seconds   1 gem installed  


這樣就下載安裝好了CocoaPods


3、使用CocoaPods

a  建立一個項目,名字PodTest



b  終端中,cd到項目總目錄(注意:包含PodTest檔案夾、PodTest.xcodeproj、PodTestTest的那個總目錄)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.