How to delete or clear a specific pod from cocoapods cache?

try 直接删除整个缓存,需要很长时间才能取回所有Pod.如何查看和移除缓存中的特定实例?

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

# 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再次从缓存中获取旧版本.

当Pod很大时,在Pod缓存中有许多相同Pod的实例可能会很麻烦,在使用cocoapods1.3.1Xcode9的项目中,当前使用的Pod之一的大小为>1.5 GB.

推荐答案

Clearing a specific pod

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

示例输出为pod cache clean 'FortifySec',对于未使用语义版本控制的pod,这可能会导致缓存中同一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?

Complete cleanup (pod reset)

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

Example of pod cache list prior to clean

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缓存.这样做是消除Pod缓存使用的不必要磁盘空间的好主意.

Ios相关问答推荐

通过在SWIFT中不起作用的泛型传递协议一致性类型

如何将Safari调试器附加到Turbo-iOS原生应用中的模拟器

有没有办法将滚动视图RTL(阿拉伯语)与Ltr动画一起使用?

在flutter中使用flatter_screenutil这样的软件包的目的是什么?

clang:错误:SDK 路径中不包含libarclite

SwiftUI 点击列表内不会触发 Select

UIView 阴影不适用于自定义扩展

iOS - 判断开发者模式是否开启 (Swift)

从iOS键盘输入时Flutter TextField输入消失

通过 Rosetta 打开模拟器 xcode 14 以修复滚动

视图之间的 SwiftUI 过渡,没有过渡

类型任何视图不能符合具有泛型的协议上的视图

如何避免任何绑定空错误并更好地获取代码

Xcode 缺少支持文件 iOS 12.2 (16E227)

在 Swift 中禁用向后滑动手势

如何在react 导航中获取当前路由名称?

如果已安装,则重定向到应用程序,否则重定向到 App Store

如何在 Objective-C (iOS) 中的图像上写文本?

正确使用 Alamofire 的 URLRequestConvertible

我在 xCode5-iOS7 中收到错误输入目录均不包含匹配的启动图像