iOS:Cocoapods 常用命令

发布时间 2023-04-21 12:02:52作者: dulinshun
命令 描述
安装与卸载
sudo gem install cocoapods 安装 cocoapods
sudo gem install cocoapods -v 1.10.0 安装 cocoapods 1.10.0 版本
sudo gem uninstall cocoapods 卸载 cocoapods
sudo gem uninstall cocoapods -v 1.10.0 卸载版本 1.10.0
---
安装在个人目录下
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
添加在 .zshrc.bashrc
不用 sudo 命令
---
Podfile 设置
source 'https://github.com/CocoaPods/Specs.git' 使用默认的资源仓库
source '私有仓库Git' 使用私有仓库
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' 使用清华大学镜像
--- ---
开发常用命令
pod setup
pod install 安装
pod install --repo-update 安装并更新仓库
已安装过的三方库,不会更新版本号
pod install --verbose
pod update AFNetworking 更新 AFNetwroking 三方库的版本
pod update 更新所有的三方库
pod repo update 更新仓库
pod repo update PrivatePodspecs 更新指定的仓库
--- ---
私有库创建与提交
pod lib create [PodName.podspec] 创建私有库(项目不存在)
pod spec create [PodName] 创建私有库(项目已存在)
pod lib lint 本地验证私有库
pob lib lint xxx.podspec 本地校验私有库
pod lib lint --allow-warnings 本地校验并忽略警告
pod lib lint --allow-warnings --verbose
pod spec lint 联网验证
pod spec lint xxx.podspec 联网验证
pod repo add <repo git> 添加一个私有Repo
pod repo push <repo git> xxx.podspec 提交到仓库
---
私有库配置信息
s.source 资源位置(一般已经配好了)
s.platform 平台以及版本号
s.requires_arc 是否进行arc
s.source_files 源文件路径(代码文件)
s.resources 资源文件(图片等)
s.frameworks 依赖的framework(系统的)
s.dependency 'AFNetworking' 依赖的三方库(线上仓库的)
s.vendored_frameworks 依赖的 frameworks (放在当前仓库中的)
s.vendored_libraries 依赖的 .a 文件 (放在当前仓库中的)
s.user_target_xcconfig 使用该仓库的 target 需要进行的配置
s.pod_target_xcconfig 当前仓库进行的配置

遇到的问题

  ### 私有库运行失败时,可以选择添加如下代码。xcode 12 以上会出现对应的错误
  s.pod_target_xcconfig     = { 'VALID_ARCHS' => 'x86_64 armv7 arm64' }