CocoaPods 使用教程,Podfile语法大全,常用命令,基本使用,2020最新教程,超详细注释

Podfile 文件

CocoaPods 是通过 Podfile 文件来管理依赖库的,该文件在项目根目录下,如果没有此文件 可通过 pod init 命令来创建或手动创建

Podfile 文件示例

platform :ios # 如果不指定版本,默认是 4.3
# platform :ios, '4.3' # iOS平台, 版本(如果不指定版本,默认是 4.3)
# platform :tvos, '9.0' # tvOS平台, 版本(如果不指定版本,默认是 9.0)
# platform :watchos, '2.0' # watchOS平台, 版本(如果不指定版本,默认是 2.0)
# platform :osx, '10.6' # macOS平台, 版本(如果不指定版本,默认是 10.6)

use_frameworks! # Swift动态库,Objetive-C 需注释掉此行

target 'targetName' do
  pod 'AFNetworking' # 不指定版本,安装最新版本
  # pod 'AFNetworking', '> 3.0' # 安装 3.0 以上版本
  # pod 'AFNetworking', '>= 3.0'  # 安装 3.0 及以上版本
  # pod 'AFNetworking', '< 3.0'  # 安装低于 3.0 版本
  # pod 'AFNetworking', '<= 3.0'  # 安装 3.0 及低于 3.0 版本
  # pod 'AFNetworking', '~> 0.1.2'  # 安装 0.1.2 及低于 0.1.2 版本,不包括 0.2 及以上版本
  # pod 'AFNetworking', '~> 0.1'  # 安装 0.1 之前的版本
  # pod 'AFNetworking', '~> 0'  # 这与不指定版本基本一致

  # 指定本地路径
  # pod 'AFNetworking', :path => '~/Documents/Alamofire'
  
  # 指定远程仓库
  # pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'
  
  # 指定分支
  # pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => 'dev'

  # 指定 tag
  # pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => '3.1.1'
  
  # 指定某次 commit
  # pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :commit => '0f506b1c45'
end

常用命令

pod init # 在当前目录生成 `Podfile` 文件
pod install # 根据 `Podfile.lock` 中的版本安装项目依赖库
pod install --verbose --no-repo-update # 只安装新增加的库,已安装的库不更新
pod update # 更新所有项目依赖库,并创建新的 `Podfile.lock` 文件
pod update xxx --verbose --no-repo-update # 只更新 xxx 库,其他库不更新
pod search xxx # 搜索 xxx 库
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Harvey66

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值