- 首先創(chuàng)建項(xiàng)目
- 終端中
cd
到當(dāng)前項(xiàng)目 - 執(zhí)行
pod init
此時(shí)項(xiàng)目中會(huì)多出一個(gè)Podfile的文件
右鍵選擇打開(kāi)方式 選擇xcode
或者直接拖拽Podfile文件到xcode
不要選擇文本編輯器打開(kāi),不然可能由于編碼問(wèn)題 后邊pod命令中會(huì)出現(xiàn)警告 - 打開(kāi)后發(fā)現(xiàn)Podfile中已經(jīng)生成了相應(yīng)的代碼
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'PodTest' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for PodTest
end
若是自己選擇
touch
命令自己建的話 還有自己輸入代碼將
# platform :ios, '9.0'
中的#
去掉 (版本改到適配版本就好)use_frameworks!
這句代碼在OC
項(xiàng)目中會(huì)是注釋狀態(tài),若是混編會(huì)報(bào)錯(cuò) 相應(yīng)框架找不到 最后直接去掉#
-
以集成
ReactiveCocoa
框架為例- 運(yùn)行
pod search ReactiveCocoa
- 找到相應(yīng)框架
- 復(fù)制
pod 'ReactiveCocoa', '~> 4.1.0'
粘貼在Podfile文件中 保存
- 運(yùn)行
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'PodTest' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for PodTest
pod 'ReactiveCocoa', '~> 4.1.0'
end
- 終端中運(yùn)行
pod install
結(jié)果如下
hideOnBush:PodTest Theshy$ pod install
Analyzing dependencies
Downloading dependencies
Installing ReactiveCocoa (4.1.0)
Installing Result (2.0.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `PodTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 2 total
pods installed.
hideOnBush:PodTest Theshy$
OK 安裝成功