安裝方式異常簡單 , Mac 下都自帶 ruby绳慎,使用 ruby 的 gem 命令即可下載安裝:
$ sudo gem install cocoapods $ pod setup
如果你的 gem 太老,可能也會有問題彩匕,可以嘗試用如下命令升級 gem:
sudo gem update --system
另外腔剂,ruby 的軟件源 https://rubygems.org 因為使用的是亞馬遜的云服務(wù),所以被墻了驼仪,需要更新一下 ruby 的源掸犬,使用如下代碼將官方的 ruby 源替換成國內(nèi)淘寶的源:
gem sources --remove https://rubygems.org/ gem sources -a https://ruby.taobao.org/ gem sources -l
還有一點需要注意,pod setup在執(zhí)行時绪爸,會輸出Setting up CocoaPods master repo湾碎,但是會等待比較久的時間。這步其實是 Cocoapods 在將它的信息下載到 ~/.cocoapods目錄下奠货,如果你等太久介褥,可以試著 cd 到那個目錄,用du -sh *來查看下載進度递惋。你也可以參考本文接下來的使用 cocoapods 的鏡像索引一節(jié)的內(nèi)容來提高下載速度柔滔。
//////新建工程 CocoaPods
suchao:Desktop dllo$ cd CocoaPods
suchao:CocoaPods dllo$ ls
suchao:CocoaPods dllo$ pod init //創(chuàng)建podfile文件
suchao:CocoaPods dllo$ pod install
編輯文件
platform :ios
pod 'RegexKitLite-NoWarning', '~> 1.1.0'
platform :ios, '7.0'
pod "AFNetworking", "~> 2.0”
suchao:CocoaPods dllo$ pod install
//////////////////////////
生敲也可以 設(shè)置這個了 就可以直接索引出了
cocoapods 無法引入頭文件的問題
選擇工程的 Target -> Build Settings 菜單,找到\”User Header Search Paths\”設(shè)置項
新增一個值"$(PODS_ROOT)"萍虽,并且選擇\”recursive\”睛廊,這樣xcode就會在項目目錄中遞歸搜索文件
屏幕快照 2015-10-29 上午11.57.48.png
使用 CocoaPods 的鏡像索引
所有的項目的 Podspec 文件都托管在https://github.com/CocoaPods/Specs。第一次執(zhí)行pod setup時杉编,CocoaPods 會將這些podspec索引文件更新到本地的 ~/.cocoapods/目錄下超全,這個索引文件比較大,有 80M 左右邓馒。所以第一次更新時非常慢嘶朱,筆者就更新了將近 1 個小時才完成。
一個叫 akinliu 的朋友在 gitcafe 和 oschina 上建立了 CocoaPods 索引庫的鏡像绒净,因為 gitcafe 和 oschina 都是國內(nèi)的服務(wù)器见咒,所以在執(zhí)行索引更新操作時,會快很多挂疆。如下操作可以將 CocoaPods 設(shè)置成使用 gitcafe 鏡像:
pod repo remove master pod repo add master https://gitcafe.com/akuandev/Specs.git pod repo update
將以上代碼中的 https://gitcafe.com/akuandev/Specs.git 替換成 http://git.oschina.net/akuandev/Specs.git 即可使用 oschina 上的鏡像改览。
、缤言、宝当、、胆萧、庆揩、俐东、、订晌、虏辫、、锈拨、
Last login: Thu Oct 29 11:09:47 on ttys003
suchao:~ dllo$ sudo gem install cocoapods
Password:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
suchao:~ dllo$ gem sougem sources --remove https://ruby.taobao.org
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sougem
suchao:~ dllo$ gem sources --remove https://ruby.taobao.org/
source https://ruby.taobao.org/ not present in cache
suchao:~ dllo$ gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org/
suchao:~ dllo$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache
suchao:~ dllo$ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources
suchao:~ dllo$ sudo gem install cocoapods
Password:
Fetching: nap-1.0.0.gem (100%)
Successfully installed nap-1.0.0
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: 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-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: cocoapods-trunk-0.6.4.gem (100%)
Successfully installed cocoapods-trunk-0.6.4
Fetching: molinillo-0.4.0.gem (100%)
Successfully installed molinillo-0.4.0
Fetching: cocoapods-0.39.0.gem (100%)
Successfully installed cocoapods-0.39.0
Parsing documentation for nap-1.0.0
Installing ri documentation for nap-1.0.0
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 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-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 cocoapods-trunk-0.6.4
Installing ri documentation for cocoapods-trunk-0.6.4
Parsing documentation for molinillo-0.4.0
Installing ri documentation for molinillo-0.4.0
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
WARNING: Unable to pull data from 'http://ruby.taobao.org/': bad response Not Found 404 (http://ruby.taobao.org/specs.4.8.gz)
11 gems installed
suchao:~ dllo$
suchao:~ dllo$ pod setup
Setting up CocoaPods master repo
Setup completed
suchao:~ dllo$ cd D
Desktop/ Documents/ Downloads/
suchao:~ dllo$ cd Desktop/
suchao:Desktop dllo$ ls
0710DistributionCer.p12
AdobeFlashPlayer_19_a_install-2.dmg
CarProfile.mobileprovision
CertificateName.p12
CertificateName.pem
CertificateSigningRequest.certSigningRequest
CocoaPods
Night
PUSHOrcal123.mobileprovision
aps_development.cer
dash
iconfont-xiala.png
ios開班用誤刪
logo
tabBar圖標
tupbiao
夜間
桌面
高亮
點擊Section下拉Cell
點擊Section下拉cell 2
啟動頁
引導頁
搖一搖 2
引導頁(完整版)
引導頁(最終版)
啟動頁Car
全屏瀏覽
可可旅行
課程代碼
課程課件
愛車達人 2
屏幕快照 2015-10-28 下午8.37.27.png
屏幕快照 2015-10-28 下午8.37.36.png
屏幕快照 2015-10-29 上午9.06.05.png
愛車達人.zip
未命名文件夾
愛車資訊截圖
未命名文件夾 2
suchao:Desktop dllo$ cd CocoaPods
suchao:CocoaPods dllo$ ls
CocoaPods CocoaPodsTests
CocoaPods.xcodeproj CocoaPodsUITests
suchao:CocoaPods dllo$ vim podfile
suchao:CocoaPods dllo$ pod install
[!] Invalid `Podfile` file: undefined method `tform' for #<Pod::Podfile:0x007fddebb1a4d8>. Updating CocoaPods might fix the issue.
# from /Users/dllo/Desktop/CocoaPods/Podfile:1
# -------------------------------------------
> tform :ios
# pod 'RegexKitLite-NoWarning', '~> 1.1.0'
# -------------------------------------------
suchao:CocoaPods dllo$ vim podfile
suchao:CocoaPods dllo$ pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.1)
Installing RegexKitLite-NoWarning (1.1.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `CocoaPods.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total
pods installed.
suchao:CocoaPods dllo$