- 首先創建項目
- 終端中
cd
到當前項目 - 執行
pod init
此時項目中會多出一個Podfile的文件
右鍵選擇打開方式 選擇xcode
或者直接拖拽Podfile文件到xcode
不要選擇文本編輯器打開,不然可能由于編碼問題 后邊pod命令中會出現警告 - 打開后發現Podfile中已經生成了相應的代碼
# 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
項目中會是注釋狀態,若是混編會報錯 相應框架找不到 最后直接去掉#
-
以集成
ReactiveCocoa
框架為例- 運行
pod search ReactiveCocoa
- 找到相應框架
- 復制
pod 'ReactiveCocoa', '~> 4.1.0'
粘貼在Podfile文件中 保存
- 運行
# 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
- 終端中運行
pod install
結果如下
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 安裝成功