- 首先创建项目
- 终端中
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 安装成功