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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46428752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:32:13  来源:igfitidea点击:

How to clear or clean specific pod from the local cocoapods cache

iosxcodecocoapods

提问by lal

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

如何从 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?

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

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` 

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

只是从 podfile 中注释掉,然后pod install再次从缓存中获取旧版本。

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.1with Xcode9.

有在群缓存相同群的许多情况下,可能会很麻烦当容器较大,目前使用的吊舱中的一个具有> 1.5 GB的大小在使用的项目cocoapods1.3.1Xcode9

回答by lal

Clearing a specific pod

清除特定的 pod

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

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',对于不使用语义版本控制的 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)

完全清理(pod 重置)

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

Example of pod cache listprior to clean

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

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.

请注意- Version: 2.2.1. 这样做是为了摆脱 pod 缓存使用的不必要的磁盘空间。