安装好pod后,
在控制台进入项目目录下,输入如下命令:
pod init
就会生成一个 Podfile 文件
打开文件,在里面输入要导入的第三方库,如:
pod 'Alamofire', '~> 5.2.2'
pod 'HandyJSON', '~> 5.0.3-beta'
整体如下
# Uncomment the next line to define a global platform for your project
# platform :ios, '14.5'
target 'PopT' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for PopT
pod 'Alamofire', '~> 5.2.2'
pod 'HandyJSON', '~> 5.0.3-beta'
target 'PopTTests' do
inherit! :search_paths
# Pods for testing
end
target 'PopTUITests' do
# Pods for testing
end
end
保存并退出之后,执行下面的命令:
pod install
提升内容有:
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
则表示安装成功!
接下来打开 PopT.xcworkspace 就可以了
如果运行 pod install 后失败了,可以去查询匹配的版本
有时候版本是正确的,但是提示连接 github 失败,如果这样,那么多运行几遍 pod install 就好了
进入项目后,如果 import Alamofire 提示不存在,可以运行一下 Alamofire 就可以了