1.首先需要安裝CocaPods:
執行下面的命令:
$ sudo gem install cocoapods
(由于天朝的長城網,上面的那個命令是無法生效的,你需要執行下面的命令)
$ sudo gem sources --remove https://rubygems.org/
//等有反應之后再敲入以下命令
$ sudo gem sources -a https://ruby.taobao.org/
下面需要輸入你的授權密碼,也就是你的登錄密碼
然后輸入pod setup --verbose 安裝需要一段時間,稍等片刻
2.導入你需要的第三方庫,例如Pop(FaceBook出品的動畫引擎庫,非常好用git地址:https://github.com/facebook/pop)
首先打開你創建的Project工程,然后進入工程文件夾:
$ cd~/Path/To/Folder/Code/PopTest
創建一個Podfile文件:
$ pod init
打開Podfile文件進行編輯,這里使用Xcode打開
$ open -a Xcode Podfile
文件內容如下:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'PopTest' do
end
你需要在target 'PopTest' do
end 之間添加你需要引用的三方庫,例如:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'PopTest' do
pod 'pop', '~> 1.0'
end
保存后,執行:
$pod install
另外,如果你使用的swift語言,則需要將下面代碼的注釋去掉
# platform :ios, '8.0'
# use_frameworks!
完