如何从本地 cocoapods 缓存中清除或清除特定的 pod

如何从 cocoapods 缓存中删除或清除特定的 pod?

尝试直接删除整个缓存,需要很长时间才能恢复所有的 pods。如何查看和删除缓存中的特定吊舱?

以下工作(较长时间提交) :

# delete all cached pods
`rm -rf "${HOME}/Library/Caches/CocoaPods"`


# delete local Pods/*
rm -rf "`pwd`/Pods/"


# pod update to fetch latest. After entire cache deletion, it takes lot longer to fetch and rebuild pod cache from scratch.
`pod update`

只要从 podfile 注释出来,pod install就可以再次从 cache 获取旧版本。

Having many instances of same pod in the pod cache can be troublesome when the pod is large, one of the pod currently in use has size of >1.5 GB in a project that is using cocoapods1.3.1 with Xcode9.

168413 次浏览

清理一个特定的逃生舱

pod cache clean --all # will clean all pods
pod cache clean 'FortifySec' --all # will remove all installed 'FortifySec' pods

对于不使用语义版本控制的 pod,pod cache clean 'FortifySec'的示例输出可能会导致在缓存中出现许多相同 pod 的副本:

pod cache clean 'FortifySec'
1: FortifySec v2.2 (External)
2: FortifySec v2.2 (External)
...
...
18: FortifySec v2.2 (External)
19: FortifySec v2.2 (External)


Which pod cache do you want to remove?

完全清理(吊舱复位)

rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
pod install

清洗前 pod cache list的例子

pod cache list


FortifySec:
- Version: 2.2.1
Type:    External
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/ui99sd....podspec.json
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/yi23sd...-sdjc3
- Version: 2.2.1
Type:    External
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/dsfs-df23
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/dfs0d-2dfs
- Version: 2.2
Type:    External
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/u78hyt....podspec.json
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/e000sd
- Version: 2.2.2
Type:    External
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/s2d-df.podspec.json
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/ds34sd....
- Version: 2.2.1
Type:    External
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/sdfsdfdsf....podspec.json
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/edfs5d7...
AFNetworking:
- Version: 2.5.3
Type:    Release
Spec:    /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/Release/AFNetworking/2.6.podspec.json
Pod:     /Users/j.d/Library/Caches/CocoaPods/Pods/Release/AFNetworking/2.6.3-4e7e2

请注意 - Version: 2.2.1的多个 pod 缓存。这样做是一个好主意,可以去掉豆荚缓存使用的不必要的磁盘空间。

安全的步骤与解释,没有豆荚退化包括和反应原生友好。

  1. 删除衍生数据-删除包含项目缓存信息的数据 Example how to do it: https://www.youtube.com/watch?v=f8bTvx0Aoyo

  2. 去掉。来自 iOS 文件夹的 xcworkspace 文件——这是在运行 pod install 时创建的 Xcode 项目文件,我们想在步骤4中重新创建它。这个项目文件使用 pods,并有一个白色的图标,而不是蓝色的基础项目没有 pods。

  3. Remove Podfile.lock - Remove old dependencies info so we can recreate them in the next step.

  4. 在 iOS 文件夹或 npx pod 中安装 pod-在 root 中安装(反应本机)-在这里我们再次下载 pod 依赖项,并且 pod 文件只有从最新的软件包锁中使用的那些文件被下载和集成,所以从 package.json 中删除的软件包 pod 已经不存在了。A.将重新生成 xcworkspace。