如何从本地cocoapods缓存中清除或清理特定的豆荚

如何从本地cocoapods缓存中清除或清理特定的豆荚

问题描述:

试图直接删除整个缓存,要花很多时间才能取回所有容器。如何查看和从缓存中删除特定的pod?

Tried deleting the entire cache directly, it takes lot of time to get back all pods. How to view and remove specific pod from cache?

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

Following works (longer time commit):

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

Just commenting out from podfile, and pod install again fetches old version from cache.

在Pod缓存较大的情况下,Pod缓存中有很多相同Pod的实例可能会很麻烦,而当前使用的其中一个Pod已具有在使用 cocoapods1.3.1 Xcode9 的项目中,文件大小大于> 1.5 GB。

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.

清除特定的容器



Clearing a specific pod

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

pod缓存干净的'FortifySec'的示例输出,对于未使用语义版本控制的Pod,这可能会导致缓存中同一Pod的许多副本:

Sample output of pod cache clean 'FortifySec', for pods not using semantic versioning, this could result in many copies of same pod in cache:

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?



完全清理(重置pod)



Complete cleanup (pod reset)

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



的示例pod缓存列表清理前



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

注意-版本:2.2.1 。这样做是为了摆脱Pod缓存使用的不必要的磁盘空间。

Notice the multiple pod cache for - Version: 2.2.1. It's a good idea to do so to get rid of unnecessary disk space used by pod cache.