Cocoapods
Pod Install
Troubleshooting
Slow Installation
iOS Development

cocoapods - 'pod install' takes forever

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

A slow pod install is usually not one bug. It is often a combination of dependency resolution cost, stale metadata, network latency, and expensive project integration work in large Xcode workspaces. The fastest fix is to identify which phase is slow and apply targeted changes.

Break pod install into Measurable Phases

Treat the install like a pipeline with separate phases:

  1. Parse Podfile and lockfile.
  2. Resolve versions.
  3. Download source archives.
  4. Integrate generated settings into Xcode project.

Start with verbose output and elapsed time:

bash
time pod install --verbose

If logs pause before downloads, resolution or metadata is likely the issue. If download lines dominate, focus on network and cache health.

Use the CDN Source and Avoid Legacy Specs Repo Costs

Modern CocoaPods works best with the CDN source. If your setup still relies on old git specs repo workflows, updates can be much slower.

ruby
1source 'https://cdn.cocoapods.org/'
2platform :ios, '14.0'
3
4target 'App' do
5  use_frameworks!
6  pod 'Alamofire', '~> 5.9'
7end

CDN mode avoids cloning massive specs history and reduces metadata update time.

Keep Lockfile Workflow Stable

A frequent cause of slow and inconsistent installs is running pod update too often. For daily development, prefer pod install and commit Podfile.lock.

Recommended workflow:

  • Use pod install for normal changes.
  • Use pod update SomePod only when upgrading intentionally.
  • Commit both Podfile and Podfile.lock.

In CI, enforce lockfile consistency:

bash
bundle exec pod install --deployment

--deployment prevents surprise re-resolution.

Clean Caches Selectively

Deleting everything can waste time. First inspect current state:

bash
pod cache list
pod env

If only one dependency is corrupted, clean that pod only:

bash
pod cache clean AFNetworking --all

Only use full reset when necessary:

bash
1rm -rf Pods
2rm -f Podfile.lock
3pod repo update
4pod install

Targeted cleanup keeps hot cache artifacts for unchanged dependencies.

Standardize Ruby and CocoaPods Tooling

Slow installs can come from inconsistent Ruby environments where gems rebuild repeatedly or use incompatible native extensions. Check active executables:

bash
1which ruby
2ruby -v
3which pod
4pod --version

Use Bundler for deterministic tooling:

bash
bundle exec pod install

This avoids machine-to-machine drift across the team.

Reduce Integration Cost in Large Workspaces

In monorepos, integration into .xcodeproj can be expensive. Keep pods scoped to relevant targets and avoid unnecessary global scripts.

ruby
1target 'AppCore' do
2  pod 'Alamofire'
3end
4
5target 'FeatureMaps' do
6  pod 'GoogleMaps'
7end

Limiting pod scope reduces generated build phase churn and speeds both install and Xcode indexing.

Diagnose Network Bottlenecks Explicitly

Corporate proxy, DNS latency, or TLS inspection can make pod install appear frozen. Validate connectivity to CocoaPods CDN and source hosts from the same environment where install runs.

For CI, keep runners close to artifact sources and enable caching between runs. Re-downloading unchanged archives every job is a common avoidable cost.

Practical Triage Playbook

Use this short sequence when install time suddenly regresses:

  1. Run pod install --verbose and note stall phase.
  2. Confirm CDN source in Podfile.
  3. Run pod repo update once.
  4. Clean only suspected pod caches.
  5. Verify Ruby and pod versions are expected.
  6. Re-run with Bundler.

This playbook fixes most slow-install incidents without destructive resets.

Common Pitfalls

  • Running pod update for routine development and forcing full resolver work.
  • Using old specs-repo assumptions instead of CDN-first configuration.
  • Deleting all caches before checking which phase is actually slow.
  • Ignoring Ruby environment drift between local and CI machines.
  • Treating network latency as a dependency conflict problem.

Summary

  • Profile install phases before choosing a fix.
  • Use CDN source and lockfile-driven workflow for speed and reproducibility.
  • Prefer selective cache cleanup over global resets.
  • Standardize Ruby and CocoaPods versions with Bundler.
  • Optimize target scoping and CI caching for large iOS codebases.

Course illustration
Course illustration

All Rights Reserved.