Swift.iOS: CocoaPods – How to Update

In this lesson

Running pod install, you notice CocoaPods is telling you about a new version, whether it is a pre-release they’d like you to try or a completely new version number. Updating to the new version is not always immediately obvious and there are several ways to go about it.

Kyle Roberts
Swift Guru at Large

Kyle's Series


Tap on time to skip ahead


So, let’s say that you’ve installed CocoaPods and this is sometime later, and they have released a new updated for CocoaPods since then. How can you update CocoaPods through Terminal?


We can see here that I ran a pod install previously and it’s telling me that there is a new test version pre-release that they’d like me to try. Why not? Let’s go for it!


There are a few ways to update CocoaPods. Since it is installed as a Ruby gem, we have several options. The one that it suggests up here is to just run the install command again, gem install cocoapods. Since it’s asking for the pre-release version we can use the –pre attribute there.


Another way to update CocoaPods is actually gem update cocoapods. That’s pretty intuitive. Again, if we want the pre-release version we will add the –pre attribute.


The final way to update CocoaPods is gem update all. That will actually go through all of the Ruby gems installed to your computer, or user account and update them all. I actually ran this yesterday on a different account so I don’t know how long it would take. It took about ten minutes over there.


Let’s just give it a shot, gem update cocoapods. And I did forget the –pre attribute but we’ll see if there’s an update anyway. It says updating installed gems. Nothing to update. Ok. So then if we say gem update cocoapods and add the –pre thing at the end, and now it’s updating CocoaPods. So, I was on the most recent version but they have a pre-release marked in GitHub probably and that’s what we’re downloading now. It looked like it was release candidate 2 from looking above. I’ll just come back in a minute when it’s finished. Oooh, and the issue that I was expecting.


A lot of time when we’re running these Ruby gem things is that they’re installed somewhere out of the directory of the current user. This current user is Brax.tv. Then we’ll need to add the sudo command to give permission for this process to execute outside of the normal write permissions for our user. Typing sudo just means you have to enter your password and it will let you continue with this operation outside of the user directory. It’s not always recommended to run commands with sudo but CocoaPods is a trustworthy source. I’m doing it. I’m taking the risk. I’m running sudo.


That downloaded a lot of stuff. And after you’ve updated your install of CocoaPods, the way to check the current version of CocoaPods is to type pod and then — version. It should print out the version number to the console.

Additional Info

Register to get access to additional resources and info.