iOS Pod 导入第三方库,如:Alamofire、HandyJSON

15 篇文章 1 订阅
8 篇文章 0 订阅

安装好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 就可以了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值