Fix: pod install Takes Forever in Xcode Projects

Fix: pod install Takes Forever in Xcode Projects

Written by

in

Quick answer: Run pod install --verbose and check whether CocoaPods stops while updating a spec repository or cloning a dependency. If it hangs on the old Git-based master specs repository, use the CocoaPods CDN for public specs; if the local trunk repository is broken, remove and recreate that repository before retrying.

Why this happens

When pod install takes forever, the delay is not necessarily an Xcode problem. CocoaPods may be fetching dependency specifications, resolving versions, or downloading a dependency’s source code. Each stage needs a different fix.

The key symptom in this case is output that stops at:

Updating spec repo `master`

$ /usr/bin/git pull --no-rebase --no-commit

This points to a Git operation against the local master specs repository, rather than a build or a download of your app’s dependencies. Older CocoaPods configurations use a Git checkout of the public specs repository. Current CocoaPods supports a CDN-based public source, avoiding that large Git checkout. A separate hang at git clone, however, usually involves the dependency being downloaded—not the specs repository.

How to fix it

1. Identify the operation that is actually stuck

Stop the current command with Control-C, then run this from the directory containing your Podfile:

pod install --verbose

If your project manages CocoaPods through a Gemfile, use its bundled version instead:

bundle exec pod install --verbose

Use that same prefix for the remaining CocoaPods commands in this guide. Switching between bundled and globally installed versions can make troubleshooting inconsistent.

Read the last complete operation in the output:

Last visible operation What to investigate
Updating spec repo master followed by git pull The legacy Git-based specs repository
A request to the CocoaPods CDN CDN access or local specs metadata
git clone for a dependency That dependency’s Git host, repository size, or authentication
Analyzing dependencies without a visible download Dependency resolution, rather than an assumed network hang

A quiet terminal alone does not prove the process is frozen. Git can spend time processing downloaded objects without continuous network activity. Verbose output gives you a specific operation to investigate instead of repeatedly clearing unrelated caches.

2. Replace the legacy public specs source with the CDN

If the log shows an update to the old public master repository, inspect the source declarations near the top of your Podfile.

For the public CocoaPods specs source, replace this legacy declaration:

source 'https://github.com/CocoaPods/Specs.git'

with:

source 'https://cdn.cocoapods.org/'

Then retry:

pod install --verbose

The CDN provides public pod specifications without requiring a local Git checkout of the entire public specs repository. This targets the specific bottleneck shown by the original git pull output.

Keep any private specs sources your project needs. Do not replace the entire source list with the public CDN if some dependencies come from an internal repository. Source ordering can also affect which repository CocoaPods uses when a pod exists in more than one source, so preserve intentional ordering.

Inspect your locally registered repositories with:

pod repo list

After confirming that your projects no longer need the legacy public Git repository, you can remove its local registration:

pod repo remove master

Do not remove master just because the name appears in an example. First verify that it is the obsolete public specs checkout, not a repository your configuration still needs. Removing a local repository does not delete its remote Git repository, but other projects on the same Mac may need that local source again.

3. Recreate a broken local trunk repository

The highest-voted solution in the source discussion resets the local repository named trunk, runs setup, and retries installation:

pod repo remove trunk
pod setup
pod install

This is a targeted recovery step when the local trunk repository or its metadata is causing trouble. Run pod repo list first to confirm that trunk exists and inspect what it represents in your installation.

The distinction matters: the reported hang mentions master, while this reset removes trunk. Removing one does not directly repair the other. If verbose output still shows a pull from the old master repository afterward, review the Podfile sources using the previous step.

The exact work performed by pod setup depends on your CocoaPods version and configuration. Do not assume it must download a large public Git repository, or that a quiet setup command necessarily failed. The useful verification is whether the subsequent install gets past the operation that previously stalled.

4. Skip repository updates when existing metadata is sufficient

If you only need to install the project’s already-resolved dependencies, try:

pod install --no-repo-update --verbose

This tells CocoaPods not to update spec repositories during that run. It can help determine whether repository refreshes are the bottleneck, and it may let an existing project install using locally available specifications.

It is not a permanent repair for missing metadata. If CocoaPods reports that it cannot find a required specification or version, the local metadata may need refreshing. Fix access to the affected source rather than repeatedly skipping its update.

Also, pod install is not the command for intentionally upgrading every existing dependency. It generally honors versions recorded in Podfile.lock. Use a targeted update when an upgrade is actually intended:

pod update SomePod

Replace SomePod with the dependency you want to update, and review the resulting lockfile changes.

5. Investigate dependency clones separately

If verbose output stops at a command such as:

/usr/bin/git clone ... --mirror

check which repository URL appears in that command. If it belongs to an individual dependency, resetting the CocoaPods specs repository will not fix that download.

A Git repository can contain substantially more history than the source files ultimately added to your project. A mirror clone can therefore take longer than expected even for a seemingly small library.

Check that you can access the repository and read its remote references:

git ls-remote https://github.com/OWNER/REPOSITORY.git

Use the actual dependency URL. If this also stalls or fails, investigate access to that Git host, network restrictions, or authentication for a private repository. Successful reference lookup confirms basic access, but it does not guarantee that a full clone will be fast.

Avoid deleting Podfile.lock as a download fix. That changes dependency resolution and can introduce unrelated version changes without addressing the stalled network operation.

How to prevent it

  • Commit Podfile.lock for app projects so installations use the agreed dependency versions.
  • Use the public CocoaPods CDN instead of an unnecessary legacy public specs Git checkout.
  • Keep required private sources documented and accessible to developers and CI.
  • Use the project’s bundled CocoaPods version when a Gemfile defines one.
  • Diagnose with --verbose before removing repositories or caches.
  • Separate routine installation from intentional dependency upgrades.

FAQ

Should I delete the Pods folder and Podfile.lock?

Not as the first response to a repository update hang. Neither addresses a stalled Git pull from the specs repository, and deleting Podfile.lock can change the versions CocoaPods resolves.

Why does removing trunk not fix Updating spec repo master?

trunk and master are separate local repository names. Inspect pod repo list and the Podfile source declarations, then repair or replace the source actually shown in the verbose log.

Does –no-repo-update prevent all downloads?

No. It skips spec repository updates, but CocoaPods may still need to download dependency source code. A hang during a dependency’s Git clone requires investigation of that repository and its network access.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.