cocoapods - 'pod install' takes forever

I was trying to update the existing pods with the pod install command, but it takes forever to run.

The verbose mode shows it was stuck at the following line (forever)

Updating spec repo master

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

There is no network activity after it gets stuck.


Solution 1:

I ran into the same problem, and I solved it by running the following commands which is given here

pod repo remove master
pod setup
pod install

Solution 2:

you can run

pod install --verbose 

to see what's going on behind the scenes.. at least you'll know where it's stuck at (it could be a git clone operation that's taking too long because of your slow network etc)

to have an even better idea of why it seems to be stuck (running verbose can get you something like this

-> Installing Typhoon (2.2.1)
 > GitHub download
 > Creating cache git repo (~/Library/Caches/CocoaPods/GitHub/0363445acc1ed036ea1f162b4d8d143134f53b92)
 > Cloning to Pods folder
       $ /usr/bin/git clone https://github.com/typhoon-framework/Typhoon.git ~/Library/Caches/CocoaPods/GitHub/0363445acc1ed036ea1f162b4d8d143134f53b92 --mirror
       Cloning into bare repository '~/Library/Caches/CocoaPods/GitHub/0363445acc1ed036ea1f162b4d8d143134f53b92'...

is to find out the size of the git repo you're cloning.. if you're cloning from github.. you can use this format:

/repos/:user/:repo

so, for example, to find out about the above repo type

https://api.github.com/repos/typhoon-framework/Typhoon

and the returned JSON will have a size key, value. so the above returned

"size": 94014,

which is approx 90mb. no wonder it's taking forever! (btw.. by the time I wrote this.. it just finished.. ha!)


update: one common thing that cocoa pods do before it even starts downloading the dependencies listed in your podfile, is to download/update its own repo (they call it Setting up Cocoapods Master repo.. look at this:

pod install --verbose

Analyzing dependencies

Updating spec repositories
  $ /usr/bin/git rev-parse  >/dev/null 2>&1
  $ /usr/bin/git ls-remote
  From https://github.com/CocoaPods/Specs.git
  09b0e7431ab82063d467296904a85d72ed40cd73  HEAD
  ..

the bad news is that if you follow the above procedure to find out how big the cocoa pod repo is.. you'll get this: "size": 614373,.. which is a lot.

so to get a more accurate way of knowing how long it takes to just install your own repo.. you can set up the cocoa pods master repo separately by using pod setup:

$ pod help setup
Usage:

$ pod setup

  Creates a directory at `~/.cocoapods/repos` which will hold your spec-repos.
  This is where it will create a clone of the public `master` spec-repo from:

      https://github.com/CocoaPods/Specs

  If the clone already exists, it will ensure that it is up-to-date.

then running pod install

Solution 3:

Updated answer for 2019 - the cocoa pods team moved to using their own CDN which solves this issue, which was due to GitHub rate limiting, as described here: https://blog.cocoapods.org/CocoaPods-1.7.2/

TL;DR You need to change the source line in your Podfile to this:

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

Solution 4:

Possible solutions:

  1. Updating Cocoa Pods may solve this issue
  2. Clean and fresh install pods again

Updating CocoaPods

Open terminal and type:

$ sudo gem update cocoapods

Reinstall Pods

Step 1

Remove all the pods from your project (tricky part):

Manually

  1. Remove all Pods records on Build Phases of your project (Marked Red)

enter image description here

  1. Remove libPods.a under Frameworks folder

enter image description here

  1. Now head to project directory and remove Podfile.lock*, **Pods folder and Workspace (Remove from Trash too).

Automatically using CocoaPods De-Integrate

Install

$ [sudo] gem install cocoapods-deintegrate

Run

$ pod deintegrate

Step 2

Here we are going through at installing the Pods again

Change your location your directory

$ cd yourprojectdirectory

Edit podfile by adding lines you need to it

$ open -a Xcode podfile 

or

$ nano podfile

FINALLY install the pod again

$ pod install

Hope this helps