Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@jk

This comment has been minimized.

Copy link

jk commented Dec 4, 2012

Why do I want to clear the cache? I'm used to just deleteing the pods dir like rm -Rf Pods; pod install in my project dir.

@mbinna

This comment has been minimized.

Copy link
Owner Author

mbinna commented Feb 18, 2013

You want to clear the cache when a pod does not use semantic versioning and just use the version 0.0.1 that points to the HEAD in the origin's master branch. Removing the caches directory of CocoaPods forces it to download the version 0.0.1 again, updating the repo with the "new" version 0.0.1.

I know that this is a dirty hack to get around semantic versioning, but during development of both an app and a corresponding static library project managed via CocoaPods, this makes sense for my scenario.

@joeluxizhi

This comment has been minimized.

Copy link

joeluxizhi commented Aug 17, 2014

This, is greatness. Save me couple days of debugging #Xcode problems

@kalehv

This comment has been minimized.

Copy link

kalehv commented Aug 22, 2014

Awesome. It's very annoying to do all those steps manually. I was thinking to write this script but was pretty sure that someone else must have been annoyed enough already and found this. Thanks.

@redwarp

This comment has been minimized.

Copy link

redwarp commented Sep 16, 2014

I also had to use it because Facebook SDK 3.18.0 could not install, with some fatal error (unable to connect to github.com), but reverting to 3.17.0 fucked up, and I had a weird error, with a missing file (FBDialogClosePNG.h not found). Clearing everything solved it for me.

@dkhamsing

This comment has been minimized.

Copy link

dkhamsing commented Mar 11, 2015

👍

@jkowalleck

This comment has been minimized.

Copy link

jkowalleck commented Jul 17, 2015

yay - cocoa pods 0.38.0.beta.1 version will bring a command for that: pod cache clean
https://github.com/CocoaPods/CocoaPods/releases/tag/0.38.0.beta.1 section "Enhancements"

@noln

This comment has been minimized.

Copy link

noln commented Aug 16, 2015

Thanks so much for sharing this! It looks like my cache was corrupted somehow, or pulled down a non-existent reference from someone else's local setup being pushed to VCS on the project I was working on. Smashed the issue. 👍

@breath103

This comment has been minimized.

Copy link

breath103 commented Nov 3, 2015

👍

@dmlebron

This comment has been minimized.

Copy link

dmlebron commented Jan 19, 2016

Thanks!

@andrewjburnett

This comment has been minimized.

Copy link

andrewjburnett commented Jan 28, 2016

Beautiful! This saved me some headache after moving an project between users on my mac.

@nonotest

This comment has been minimized.

Copy link

nonotest commented Jan 29, 2016

cheers

@ipedro

This comment has been minimized.

Copy link

ipedro commented Mar 13, 2016

nice!

@ngheungyu

This comment has been minimized.

Copy link

ngheungyu commented Jun 26, 2016

Cleaning the cache doesn't mean Xocde will read the new code! One extra tips is to delete the Derived Data to prevent compiler reading the old code. Hope it helps

@justinswart

This comment has been minimized.

Copy link

justinswart commented Jun 30, 2016

rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install;
@uzuume

This comment has been minimized.

Copy link

uzuume commented Jul 22, 2016

Thanks!

@orenk86

This comment has been minimized.

Copy link

orenk86 commented Aug 28, 2016

Clean, simple, perfect. Thanks!

@andj207

This comment has been minimized.

Copy link

andj207 commented Nov 10, 2016

It works. Thanks.

@jeantimex

This comment has been minimized.

Copy link

jeantimex commented Dec 8, 2016

Thanks mate, I hate caches!

@syzer

This comment has been minimized.

Copy link

syzer commented Aug 15, 2017

Thanks!

@cprovatas

This comment has been minimized.

Copy link

cprovatas commented Sep 13, 2017

<3

@ashokds

This comment has been minimized.

Copy link

ashokds commented Sep 26, 2017

👍 Thanks!

pod cache clear --all
pod cache clear 'alamofire'
pod cache clear 'alamofire' --all // delete all installed 'alamofire' pods

@efremidze

This comment has been minimized.

Copy link

efremidze commented Oct 2, 2017

Use clean instead of clear.

pod cache clean --all
pod cache clean 'alamofire'
pod cache clean 'alamofire' --all

@olgusirman

This comment has been minimized.

Copy link

olgusirman commented Nov 15, 2017

Thanks, I use it all the time!

@Urvish-modi

This comment has been minimized.

Copy link

Urvish-modi commented Jan 31, 2018

Unable to understand what happens, i command pod install with repo update and this happens.
Anyone has idea ?

screen shot 2018-01-31 at 11 05 09 am

screen shot 2018-01-31 at 11 06 04 am

@RishabhTayal

This comment has been minimized.

Copy link

RishabhTayal commented Apr 27, 2018

This is AWESOME! 👍

@kr-mohak

This comment has been minimized.

Copy link

kr-mohak commented Apr 17, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.