How to clear or clean specific pod from the local cocoapods cache
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If one CocoaPod is stale or corrupted, you usually do not need to wipe the entire CocoaPods cache. CocoaPods can clean a specific pod from the local cache so the next install fetches it again. The normal command is pod cache clean <PodName> --all, and the rest of the workflow is about confirming the cached versions and forcing a clean reinstall in the project.
Check What Is Cached First
Before deleting anything, inspect the cache for the pod you care about.
This shows which cached versions CocoaPods knows about for that pod. If the output includes versions you no longer want, that confirms you are targeting the right cache entry.
You can also inspect the broader cache:
That is useful when you are not yet sure whether the problem is really tied to one dependency.
Clean a Specific Pod
The main command is:
This removes all cached versions of Alamofire from the CocoaPods cache.
If you want to target a specific version only, some CocoaPods workflows allow narrower cleaning, but --all is the usual fix when the goal is “get rid of this pod locally and redownload it cleanly.”
Reinstall After Cleaning
Cleaning the cache alone does not modify your project’s installed Pods directory. After clearing the cached copy, reinstall the dependency in the project.
A common sequence is:
This forces CocoaPods to resolve and download fresh pod contents instead of reusing a stale local install.
Be careful with Podfile.lock. Removing it changes dependency resolution and may upgrade versions. If you want to preserve the locked versions, keep Podfile.lock and just run pod install after cleaning the cache.
Know the Difference Between Cache and Project State
There are two separate things here:
- CocoaPods global cache on your machine
- the
Pods/directory inside the current project
Cleaning the global cache removes downloaded pod archives or prepared sources. It does not automatically remove the copy already integrated into your current project.
That is why a full local reset often includes both:
- clean the global cache for the specific pod
- remove and reinstall the project’s pod integration if necessary
When Cleaning a Specific Pod Helps
Targeted cache cleaning is especially useful when:
- one pod seems corrupted locally
- a podspec changed and the cached copy is stale
- builds fail only for one dependency
- you want to re-fetch a pod without destroying the entire CocoaPods cache
It is a much more surgical fix than deleting every cached pod on the machine.
When the Problem Is Not the Cache
Sometimes developers clean the cache when the real issue is elsewhere, such as:
- Xcode derived data
- a bad lockfile resolution
- a broken local podspec repo
- incompatible Swift or Xcode versions
So if cleaning the pod cache does not help, widen the troubleshooting scope rather than repeating the same cache command.
Example Recovery Flow
For one problematic pod, a practical recovery flow is:
If the issue still persists, then consider:
That sequence separates cache issues from build-cache or spec-repo issues.
Common Pitfalls
A common mistake is cleaning the global pod cache and expecting the already-installed Pods/ directory in the project to change automatically. It will not.
Another issue is deleting Podfile.lock casually. That can upgrade dependencies when the real goal was only to redownload the existing locked versions.
Developers also sometimes wipe the entire CocoaPods cache when only one pod is problematic. That is unnecessary most of the time.
Finally, if the build issue comes from Xcode derived data or toolchain mismatch, pod-cache cleaning alone will not solve it.
Summary
- Use
pod cache clean <PodName> --allto remove one pod from the local CocoaPods cache. - Check cached versions first with
pod cache list <PodName>. - Cleaning the global cache does not automatically remove the pod already installed in the project.
- Reinstall the project pods afterward if you want a fresh local integration.
- If cleaning one pod does not help, investigate lockfiles, derived data, and podspec state as separate issues.

