457

How can I downgrade Cocoapods to an older version, or how can I install an older version of Cocoapods?

mfaani
  • 33,269
  • 19
  • 164
  • 293
a fair player
  • 11,530
  • 9
  • 46
  • 48

8 Answers8

908

to remove your current version you could just run:

sudo gem uninstall cocoapods

you can install a specific version of cocoa pods via the following command:

sudo gem install cocoapods -v 0.25.0

You can use older installed versions with following command:

pod _0.25.0_ setup
NSMutableString
  • 10,493
  • 1
  • 21
  • 27
  • 84
    To see which version you currently have, run `sudo gem list cocoapods` – SwiftArchitect Apr 30 '15 at 19:25
  • 10
    This is brilliant! I had upgraded to 0.38, and with that version I was getting errors. All I had to do to revert to 0.37 was run your comment `sudo gem uninstall cocoapods` and then pick 0.38 from the automatically presented list. Within seconds I was back on 0.37, and my pod install worked again! Thanks so much! – Erik van der Neut Jul 21 '15 at 02:42
  • 3
    Great thx! Just one comment, if you are using rvm, omit the sudo since its going to uninstall/install in the usr/bin instead of your rvm installation directory – AkademiksQc Aug 27 '15 at 13:34
  • 9
    Update... if you call `gem uninstall cocoapods` it will now ask you which version you want to uninstall. Much quicker! :o) – ingh.am Sep 30 '15 at 13:58
  • 1
    Cocoapods 1.0.0 Update: note that if you have 1.0.0 installed, attempting to reinstall an older version on top will leave 1.0.0 as the default version, so you have to `sudo gem uninstall cocoapods` first, then select 1.0.0 as the version to remove. Not sure if this has always been the behavior, but `sudo gem install cocoapods -v 0.39.0` alone didn't do the trick for me once I had 1.0.0. – fullofsquirrels May 23 '16 at 16:43
  • If you see the error message "You don't have write permissions for the /usr/bin directory." on macOS High Sierra, use: `sudo gem install cocoapods -v 1.3.1 -n /usr/local/bin` referenced from https://stackoverflow.com/questions/2893889/how-do-i-fix-the-you-dont-have-write-permissions-into-the-usr-bin-directory?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – allenlinli Apr 25 '18 at 11:17
  • You can also remove a specific version of cocoapods like: `sudo gem uninstall cocoapods -v 1.7.5 `. This is specially useful if you want to revert to an older version as removing the current/latest version reverts it back to last installed version. If there is no other version installed you can installed the one you want like: `sudo gem install cocoapods -v 1.6.0` – nomann Aug 14 '19 at 15:53
103

Actually, you don't need to downgrade – if you need to use older version in some projects, just specify the version that you need to use after pod command.

pod _0.37.2_ setup
Augard
  • 1,299
  • 1
  • 8
  • 10
  • Thanks, it kind of worked, but I had some ruby cocoapods-rome warnings so I ended up uninstalling cocoapods completely and installing only the older version. – Marián Černý Sep 04 '15 at 08:00
  • 1
    I think this is a much better solution. There are unfortunate situations where you need different versions of cocoa pods for different projects and it's convenient to not have to uninstall and reinstall cocoa pods each time – Jeff Ames Nov 28 '15 at 05:25
  • 10
    This doesn't work for me, neither `pod _0.39.0_ install`. If I run that and then run `pod --version` it still shows the latest version. – Mauricio Oct 20 '18 at 20:30
  • you have to first install it with `sudo gem install cocoapods -v 0.39.0` , it will work after that – Alberto M Apr 12 '19 at 13:41
  • I can confirm that this doesn't work. Even with the required version installed, Cocoapods ignores the version specified and uses the latest installed version. – Anthony Oliveri Sep 24 '19 at 18:53
  • Just got it to work. I completely uninstalled all traces of cocoapods (using `gem list --local` as a guide), then installed cocoapods with `sudo gem install cocoapods -n /usr/local/bin`. Now, doing `pod _1.5.3_ install` uses 1.5.3 instead of the latest 1.8.0, even with both installed. – Anthony Oliveri Sep 24 '19 at 19:22
41

Several notes:

Make sure you first get a list of all installed versions. I actually had the version I wanted to downgrade to already installed, but ended up uninstalling that as well. To see the list of all your versions do:

sudo gem list cocoapods

Then when you want to delete a version, specify that version.

sudo gem uninstall cocoapods -v 1.6.2

You could remove the version specifier -v 1.6.2 and that would delete all versions:

You may try all this and still see that the Cocoapods you expected is still installed. If that's the case then it might be because Cocoaposa is stored in a different directory.

sudo gem uninstall -n /usr/local/bin cocoapods -v 1.6.2

Then you will have to also install it in a different directory, otherwise you may get an error saying You don't have write permissions for the /usr/bin directory

sudo gem install -n /usr/local/bin cocoapods -v 1.6.1

To check which version is your default do:

pod --version

For more on the directory problem see here

mfaani
  • 33,269
  • 19
  • 164
  • 293
35

If you need to install an older version (for example 0.25):

pod _0.25.0_ install
Ori
  • 632
  • 7
  • 19
  • 2
    This doesn't work for me. If I run this and the run `pod --version` it still shows the latest version. – Mauricio Oct 20 '18 at 20:28
  • `pod --version` will always show the newest version. Use the example above to install an older version (in the example above the older version is 0.25.0) – Ori Oct 22 '18 at 09:13
  • 2
    In my case using `pod _1.5.3_ install` has the behavior of the new 1.7.x versions, so I'm really questioning about the reliability of this syntax… – AnthoPak Mar 14 '19 at 13:47
  • 2
    This DOES work. I was able to use 1.7.5 while my latest version was 1.8.4. – CodeReaper Feb 24 '20 at 10:32
26
PROMPT> gem uninstall cocoapods

Select gem to uninstall:
 1. cocoapods-0.32.1
 2. cocoapods-0.33.1
 3. cocoapods-0.36.0.beta.2
 4. cocoapods-0.38.2
 5. cocoapods-0.39.0
 6. cocoapods-1.0.0
 7. All versions
> 6
Successfully uninstalled cocoapods-1.0.0
PROMPT> gem install cocoapods -v 0.39.0
Successfully installed cocoapods-0.39.0
Parsing documentation for cocoapods-0.39.0
Done installing documentation for cocoapods after 1 seconds
1 gem installed
PROMPT> pod --version
0.39.0
PROMPT>
neoneye
  • 50,398
  • 25
  • 166
  • 151
7

In my case I had to uninstall from homebrew

brew uninstall cocoapods
Murilo Medeiros
  • 251
  • 2
  • 12
4

Note that your pod specs will remain, and are located at ~/.cocoapods/ . This directory may also need to be removed if you want a completely fresh install.

They can be removed using pod spec remove SPEC_NAME then pod setup

It may help to do pod spec remove master then pod setup

nyarasha
  • 1,119
  • 1
  • 14
  • 24
Vlad
  • 5,727
  • 3
  • 38
  • 59
3

In some cases, one needs to remove some hidden artefacts in the home directory so that the up- or downgrade takes effect:

rm -rf ~/.cocoapods
Lukas Mohs
  • 290
  • 3
  • 4