换源
gitee(更快)
cd ~/.cocoapods/repos
pod repo remove master
#gitee镜像 (此镜像更快速,几m每秒)
git clone https://gitee.com/mirrors/CocoaPods-Specs.git master
#把项目podfile里的source换:
source 'https://gitee.com/mirrors/CocoaPods-Specs.git'
清华
CocoaPods | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
# 源本地路径
cd ~/.cocoapods/repos
pod repo remove master
# clone 后,本地会员文件夹master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
#在项目的podfile 文件添加下面一行
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
#然后和以前一样,使用pod install进行安装
清空项目,重新install
//清除缓存
pod cache clean --all
//移出本地 pod文件依赖
pod deintegrate
//重新安装
pod install
podfile内容
cd 到工程目录
vim Podfile
#添加
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
# 以 RxSwift 为例
use_frameworks!
# SpaceXLaunch 是项目名
target 'SpaceXLaunch' do
pod 'RxSwift', '6.5.0'
pod 'RxCocoa', '6.5.0'
end
错误
pod install
错误 RuntimeError - [Xcodeproj] Unknown object version (56).
xcode 14 安装报错
pod repo update
改完就可以了
初次安装会出现 xcworkspace ,打开这个
错误CocoaPods could not find compatible versions for pod
删除 Podfile.lock , 再执行
pod repo update
如果还不行,就执行下面命令,注意这会导致全部拉取一遍,非常耗时
#从 CocoaPods 中分离您的项目。 从您的 Xcode 项目中删除所有 CocoaPods 的痕迹。如果未指定 xcodeproj,则将在当前目录中搜索 Xcode 项目
pod deintegrate
pod install
pod update
命令
pod install
用于添加或移除第三方库框架
具体的工作流程:
如果Podfile.lock文件存在, 则直接从此文件中读取框架信息,并且它会只下载Podfile.lock文件中指定的版本安装。对于不在Podfile.lock文件中的pod库,pod install命令会搜索这个pod库在Podfile文件中指定的版本来安装;
如果Podfile.lock不存在, 则会读取Podfile文件内的框架信息,然后执行下载并且根据下载好的框架信息, 生成Podfile.lock文件。
pod install --repo-update
根据Podfile文件或者Podfile.lock下载并导入对应的第三方库,检查资源配置文件是否需要有更新,如有更新,则下载最新版本。
pod update
当你想要更新pod库的版本时才使用pod update。
具体的工作流程:
1 先拉取远程最新目录,再根据目录中的资源重新更新一遍pod
2 它不管Podfile.lock是否存在, 都会读取Podfile文件的的框架信息。如果你的podfile中每个库都指定了版本还好,如果没有,那么每次都是拉一遍最新库。如果不想每次都拉一遍最新库,就要用到命令pod update --no-repo-update,这条命令表示只根据本地目录更新库,不需要拉取远程。
pod update xxx
查找更新最新版本的指定库名称的框架
如pod update SDWebImage。
pod repo update
用来更新本地cocoapods的spec资源配置信息。
可能你从来不会用pod repo update也可以拿到最新的库,那是因为在使用pod update是默认会执行一遍pod repo update ,所以会发现如果你的pod库引用多了,每次pod update都很慢,网络如果不好更是经常会断掉,就是因为你在更新pod时,也更新了资源目录。
pod repo update ~/.cocoapods/repos/***/
只想更新某个具体的私有库。
有时候会引用一些私有库 , pod repo update 会把 ~/.cocoapods/repos/这个目录下所有的资源库目录都更新一遍,而pod repo update ~/.cocoapods/repos/***/只想更新某个具体的私有库。