Swift.iOS: CocoaPods – Installing Pods

In this lesson

Podfiles! Podfiles! What to do with all these Podfiles? Why not use them for good by running good ole pod install to install dependencies to projects and create workspaces!

Kyle Roberts
Swift Guru at Large

Kyle's Series

Transcript

Tap on time to skip ahead

00:10

Hello world. Kyle here with Brax.tv. We’re going to talk about how to install Pods using CocoaPods from a Podfile. Here’s the Podfile I have from my SteamReader app. We have six pods ready to install here. I have already installed them, you can see they are already in the project. But we can run another pod install and if there have been any changes or anything to update it will just overwrite anything that’s here already. If there’s nothing to change, then nothing is going to change.

00:51

All you have to do is navigate to your project directory. The directory that holds the Xcode project, possibly the Xcode workspace, depending on if you’re using the workspace or if you’ve install any Pods already. All you have to do is navigate to your project directory. We just have to make sure in terminal that we have navigated to our directory. I’ll just run a ls command to see and we can compare and that’s the same content as above.

01:20

Now, all we have to do is run pod install and since we’re in this directory CocoaPods is going to open this Podfile, look through all the resources and start installing them. With this command you do not have to run sudo at all.

01:35

It says it’s recreating CocoaPods due to a major version update. It’s analyzed the Podfile, it’s downloading the dependencies and then it’s installing them to the Pods project and regenerating that here and integrating client projects. That is when it will also add the original Xcode project to the workspace. Sending stats, that’s an anonymous user stats thing that it sends to CocoaPods for their analytics. Then it says it’s complete. Six dependencies installed from the Podfile and six total installed.

02:08

Now sometimes this number of total pods installed is higher than original dependencies from the Podfile. In a situation like that, let me open up the Podfile. If I would take Alamofire off of this and then save that with Command+S and rerun pod install, then it’s going to say that there were five dependencies from the Podfile since we actually removed one of them so now there’s five total. But since AlamofireImage requires the Alamofire pod it’s going to install the Alamofire pod as well. So then six total pods installed. That’s how you install CocoaPods. It’s as simple as running pod install in the correct directory.   

Additional Info

Register to get access to additional resources and info.