CocoaPods Cache Taking Up Too Much Disk Space on Mac?

How to find and clean CocoaPods cache, Pods directories, spec repos, and related artifacts on macOS -- reclaim 5-20GB

If you have been developing iOS or macOS apps with CocoaPods, your machine has accumulated downloads, spec repos, and Pods directories that may be taking up 5-20GB of SSD space. Even if you no longer use CocoaPods, leftover caches may still be lurking on your disk.

This guide covers every location where CocoaPods stores data and shows you how to reclaim that space safely.

Table of Contents

1. Audit Your CocoaPods Disk Usage

CocoaPods stores data in several locations. Let's check them all:

# Pod download cache
du -sh ~/Library/Caches/CocoaPods

# Spec repo (the dependency catalog)
du -sh ~/.cocoapods/repos

# CocoaPods home directory
du -sh ~/.cocoapods

# Find all Pods/ directories in your projects
find ~/Projects -name "Pods" -type d -maxdepth 3 -exec du -sh {} + 2>/dev/null | sort -hr

Typical breakdown on a developer machine:

LocationTypical SizeWhat It Contains
~/Library/Caches/CocoaPods2-10GBDownloaded pod source archives
~/.cocoapods/repos/trunk500MB-2GBMaster spec repository (JSON podspecs)
Per-project Pods/200MB-2GB eachInstalled dependencies for each project
Xcode DerivedData (pod targets)1-5GB per projectCompiled pod frameworks
Why so large? CocoaPods downloads and caches every version of every pod you have ever installed. The spec repo alone contains metadata for 90,000+ libraries. Each project's Pods/ directory contains the full source code of all dependencies.

2. Clean the Pod Download Cache

The download cache at ~/Library/Caches/CocoaPods stores compressed archives of every pod version you have ever installed.

Use the built-in command

# List cached pods
pod cache list

# Clean all cached downloads
pod cache clean --all

# Clean a specific pod's cache
pod cache clean AFNetworking

Manual cleanup (more thorough)

# Check size before
du -sh ~/Library/Caches/CocoaPods

# Remove the entire cache directory
rm -rf ~/Library/Caches/CocoaPods

# CocoaPods recreates it on next pod install
Is it safe? Yes. The download cache is just a local mirror of pods. Running pod install re-downloads anything needed. Your next install will be slower but nothing breaks.

3. Remove the Spec Repos

The spec repo at ~/.cocoapods/repos is a full clone of the CocoaPods spec database. Since CocoaPods 1.8+, the default is the CDN-based trunk, but you may still have old repos:

# See all spec repos
pod repo list

# Check sizes
du -sh ~/.cocoapods/repos/*

# Example:
# 1.2G  ~/.cocoapods/repos/trunk
# 850M  ~/.cocoapods/repos/master  (legacy, pre-CDN)

# Remove the old master repo if you have it
pod repo remove master

# Or remove all repos
rm -rf ~/.cocoapods/repos

# CocoaPods recreates trunk on next use
The master vs trunk difference: Before CocoaPods 1.8, the full Git repo (master) was cloned (~3GB). Now CocoaPods uses a CDN-backed trunk which is lighter. If you see master in your repos, you can safely remove it.

4. Find and Clean Pods/ Directories

Each project using CocoaPods has a Pods/ directory containing the actual source code of all dependencies. This is often the largest consumer of space.

# Find all Pods directories across your projects
find ~ -name "Pods" -type d -maxdepth 4 2>/dev/null | while read dir; do
    size=$(du -sh "$dir" 2>/dev/null | cut -f1)
    echo "$size  $dir"
done | sort -hr

# Total size of all Pods directories
find ~/Projects -name "Pods" -type d -maxdepth 3 -prune -exec du -sk {} + 2>/dev/null | awk '{sum+=$1} END{printf "Total: %.1f GB\n", sum/1048576}'

Clean Pods for inactive projects

# Remove Pods from a specific project (can re-install later)
cd ~/Projects/MyOldApp
rm -rf Pods

# To restore: just run pod install
pod install

# Remove Pods from ALL projects (aggressive but saves lots of space)
find ~/Projects -name "Pods" -type d -maxdepth 3 -prune -exec rm -rf {} + 2>/dev/null
Keep your Podfile.lock! The Podfile.lock file records the exact versions of your dependencies. As long as you have this file, pod install restores the exact same versions. Never delete Podfile.lock unless you want to update dependency versions.

5. Clean Xcode Build Artifacts for Pod Projects

When Xcode builds a CocoaPods project, it compiles every pod into frameworks stored in DerivedData. These can be massive:

# Check DerivedData size
du -sh ~/Library/Developer/Xcode/DerivedData

# Find largest DerivedData entries
du -sh ~/Library/Developer/Xcode/DerivedData/* 2>/dev/null | sort -hr | head -10

# Clean all DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/*

# Or use Xcode: Product > Clean Build Folder (Shift+Cmd+K)

Also check the Xcode archives if you have old builds:

# Xcode archives (old build artifacts)
du -sh ~/Library/Developer/Xcode/Archives/*

# Remove old archives
find ~/Library/Developer/Xcode/Archives -maxdepth 1 -type d -mtime +90 -exec rm -rf {} +

6. Deintegrate CocoaPods from Projects

If you have migrated a project to Swift Package Manager or no longer need CocoaPods, you can fully remove it:

# Install the deintegrate plugin
gem install cocoapods-deintegrate

# Navigate to the project
cd ~/Projects/MyApp

# Remove CocoaPods integration from the Xcode project
pod deintegrate

# Remove related files
rm -rf Pods
rm Podfile
rm Podfile.lock
rm -rf *.xcworkspace
Warning: After deintegrating, your project will not compile until you either add dependencies via another method (like SPM) or remove the import statements for pods you were using.

7. Fully Uninstall CocoaPods

If you no longer use CocoaPods at all, remove everything:

# Uninstall CocoaPods gem
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core cocoapods-deintegrate cocoapods-downloader cocoapods-plugins cocoapods-search cocoapods-trunk

# Remove all CocoaPods data
rm -rf ~/.cocoapods
rm -rf ~/Library/Caches/CocoaPods

# Remove the CocoaPods gem cache
gem cleanup

# Verify removal
which pod  # should show nothing

8. Migrating to Swift Package Manager

Swift Package Manager (SPM) is built into Xcode and has several advantages for disk space:

FeatureCocoaPodsSwift Package Manager
Source in projectFull copy in Pods/Shared cache (~/Library/Developer/...)
Spec repository500MB-2GB local cloneNo local repo needed
Workspace fileGenerates .xcworkspaceBuilt into .xcodeproj
Shared across projectsNo (each has own Pods/)Yes (Xcode caches packages globally)
Typical overhead per project200MB-2GBMinimal (shared cache)

Most popular pods now support SPM. Check the library's repo for a Package.swift file.

# In Xcode: File > Add Package Dependencies
# Paste the GitHub URL of the library
# Xcode handles the rest

# SPM packages are cached at:
du -sh ~/Library/Developer/Xcode/DerivedData/*/SourcePackages

9. Automate CocoaPods Cleanup

#!/bin/bash
# cocoapods-cleanup.sh -- Clean CocoaPods caches

echo "=== CocoaPods Disk Audit ==="
echo "Download cache: $(du -sh ~/Library/Caches/CocoaPods 2>/dev/null | cut -f1)"
echo "Spec repos:     $(du -sh ~/.cocoapods/repos 2>/dev/null | cut -f1)"

BEFORE=$(du -sk ~/Library/Caches/CocoaPods ~/.cocoapods 2>/dev/null | awk '{sum+=$1} END{print sum}')

echo ""
echo "=== Cleaning download cache ==="
rm -rf ~/Library/Caches/CocoaPods

echo "=== Cleaning old spec repos ==="
rm -rf ~/.cocoapods/repos/master 2>/dev/null

echo "=== Cleaning lock files ==="
find ~/.cocoapods -name "*.lock" -delete 2>/dev/null

AFTER=$(du -sk ~/Library/Caches/CocoaPods ~/.cocoapods 2>/dev/null | awk '{sum+=$1} END{print sum}')
SAVED=$(( (BEFORE - AFTER) / 1024 ))
echo ""
echo "=== Done! Freed approximately ${SAVED}MB ==="
Skip the manual work. ClearDisk automatically finds and cleans CocoaPods cache, Xcode DerivedData, node_modules, Docker images, and 15+ other developer cache types from your Mac's menu bar -- free and open source.

brew tap bysiber/cleardisk && brew install --cask cleardisk

Complete CocoaPods Disk Cleanup Cheatsheet

# === AUDIT ===
du -sh ~/Library/Caches/CocoaPods      # download cache
du -sh ~/.cocoapods/repos              # spec repos
du -sh ~/.cocoapods                    # total CocoaPods home
pod cache list                         # list cached pods

# === SAFE CLEANUP ===
pod cache clean --all                  # clean download cache
pod repo remove master                 # remove old spec repo

# === MODERATE ===
rm -rf ~/Library/Caches/CocoaPods      # nuke download cache
rm -rf ~/.cocoapods/repos              # remove all spec repos
rm -rf ~/Projects/OldApp/Pods          # remove project pods

# === AGGRESSIVE ===
find ~/Projects -name "Pods" -type d -maxdepth 3 -prune -exec rm -rf {} +

# === NUCLEAR (full uninstall) ===
sudo gem uninstall cocoapods
rm -rf ~/.cocoapods
rm -rf ~/Library/Caches/CocoaPods

# === ALSO CLEAN ===
rm -rf ~/Library/Developer/Xcode/DerivedData/*  # Xcode build artifacts
gem cleanup                            # Ruby gem cache

Frequently Asked Questions

How much space can I recover from CocoaPods?

Typically 5-20GB depending on the number of projects and pods used. The download cache and per-project Pods/ directories are the largest consumers. If you also clean DerivedData, expect to save even more.

Will pod cache clean remove things I need?

No. pod cache clean --all only removes the local download cache. Your projects still have their Pods/ directories intact. The cache just speeds up future installs so they do not have to re-download from the network.

Can I safely delete the Pods/ directory?

Yes, as long as you keep the Podfile and Podfile.lock. Running pod install restores everything to the exact same state. Many teams even gitignore the Pods/ directory.

Is CocoaPods still maintained?

CocoaPods is in maintenance mode. Apple's Swift Package Manager is now the recommended dependency manager for Apple platforms. If you are starting a new project, consider using SPM instead. For existing projects, CocoaPods still works but consider migrating dependencies that support SPM.

What about Carthage?

Carthage stores builds at Carthage/Build and checkouts at Carthage/Checkouts in each project. You can safely delete both directories and rebuild with carthage bootstrap.