一 先安裝Ruby環境:
http://ruby-china.org/wiki/install_ruby_guide
在安裝的時候,若是出現:
1.You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
就在命令前加一個sudo獲得管理員權限,eg: sudo gem install bundler
2.Error installing rails:activesupport requires Ruby version >= 2.2.2.
macOS 自身已經安裝了 Ruby 了,版本應該比較低的,直接按照上面命令安裝,會提示 Ruby 版本不夠的錯誤信息,可以參考http://blog.csdn.net/lissdy/article/details/9191351進行更新,要走注意輸入版本號的正確性,eg:rvm install 2.3是正確的,而rvm install 2.3.0是錯誤的
二 安裝CocoaPods:
$ sudo gem install cocoapods
1.當pod setup 進入Setting up CocoaPods master repo 等待的時候表示正在下載了,此時你可通過新開一個終端窗口,輸入"cd ~/.cocoapods/"命令行跳到cocoapods文件夾內,執行"du -sh *"查看正在下載的文件夾的大小
$ pod search AFNetworking 檢查是否成功安裝CocoaPods
三 使用CocoaPods:
1.直接將根目錄拖拽進命令行窗口即可
cd + 文件路徑
2.創建Podfile文件(不能使用文本編輯編輯內容)
vim Podfile
1)The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.
解決方式為將Podfile 內填寫格式改為如下: (TestThirdParty 改為自己項目名)
platform :ios, '8.0'
use_frameworks!
target 'TestThirdParty' do
pod 'AFNetworking', '~> 2.6'
//可以連續pod多個第三方
// pod 'B','版本'...
end
2)Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
解決辦法為不要使用文本編輯去編輯Podfile,使用Xcode編輯,或者使用終端敲命令去編輯。或者輸入格式錯誤,沒輸入運行版本:$platform:ios, ‘9.0‘
3.根據Podfile文件安裝第三方框架
pod install



