iOS 简单给项目添加pod
2017-11-07 本文已影响0人
winsonGali
老是会忘,毕竟不会频繁新建项目。以前怎么弄得也忘得差不多了,曾经有段时间习惯使用Xcode的CocoaPods插件来安装,后来Xcode不支持插件了,就用终端来安装,代码这种东西,学而不时习之,就是会忘。
1. 新建工程 PodTest
2. 打开终端,cd到 PodTest 根目录
3. 在终端输入 "pod init",会自动创建一个名为 Podfile 的文件
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'PosTest' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for PosTest
target 'PosTestTests' do
inherit! :search_paths
# Pods for testing
end
target 'PosTestUITests' do
inherit! :search_paths
# Pods for testing
end
end
4. 编辑 Podfile 文件
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'PosTest' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for PosTest
pod 'SVProgressHUD', :git => 'https://github.com/SVProgressHUD/SVProgressHUD.git'
target 'PosTestTests' do
inherit! :search_paths
# Pods for testing
end
target 'PosTestUITests' do
inherit! :search_paths
# Pods for testing
end
end
5. 在终端输入 "pod install",等待下载完成。
pod install
6. 回到工程目录,双击“PosTest.xcworkspace”进入程序
以下是整个终端输入的代码:
WinsondeMacBook-Pro:~ Winson_microlink$ cd /Users/Winson_microlink/Documents/Xcode\ Projects/PosTest
WinsondeMacBook-Pro:PosTest Winson_microlink$ pod init
WinsondeMacBook-Pro:PosTest Winson_microlink$ pod install
Analyzing dependencies
Pre-downloading: `SVProgressHUD` from `https://github.com/SVProgressHUD/SVProgressHUD.git`
Downloading dependencies
Installing SVProgressHUD (2.2.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `PosTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
[!] Automatically assigning platform ios with version 11.0 on target PosTest because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
WinsondeMacBook-Pro:PosTest Winson_microlink$