Beginners guide to implementing Cocoa Pods into your Xcode iOS project

If you’ve heard about Cocoa Pods but never found the time to investigate — this is for you. Our plan is to create a new Xcode / iOS / Swift project that uses the Parse framework — built with the help of Cocoa Pods.

The target audience is beginners.

We’ll implement all this across 8 chapters — finishing up with some links.

Time to try a new post style …

Visitors to my blog will be used to my in-depth posts. Well I’m going to try something new. Same depth of content but with SOME video. I have broken the post down into chapters, each with a slide, text and maybe a video.

Hopefully I will figure out how to make the videos sharper and the image more detailed.

Fingers crossed this works and I don’t bore you all to sleep!

Our system baseline is the latest as of today (Mid September 2015). We’ll be using current releases — no betas here.

I doubt having different versions will make much of a difference. Sure you might need to change syntax a little if you’re using an older version of Swift or even a newer version of Swift. But I am sure you’ll be able to figure that out.

I added this chapter because I have learned that sometimes it’s easy to get carried away in the heat of the moment and do something that changes your project maybe in ways that you didn’t expect — maybe even breaking your project. Even worse — a poor quality Pod might introduce security issues that you are not aware of.

With Pods’ it’s important to remember that you are delegating responsibility for portions of your project to someone else. You should check before you take this step. Go investigate how often the Pod is updated — is it actively maintained? Check the list of known issues — are there so many to suggest you’re about to enter bug hell.

Does the Pod have a release schedule? Is there a future roadmap? You might want to check that updates and releases will fall happy for your project and that the overall direction of the Pod is aligned to your future project strategy.

It’s worth remembering that most Pods’ are created/managed and supported by a group of volunteers. Maybe you can join the group. Maybe you can donate some time to the cause. I wouldn’t worry about not being technical or skilled enough. Just following the team and reading their documentation will improve your skills. Hell — most volunteer projects need testers and document writers. You should attempt to get stuck in.

Now all this might sound very negative. I’m just being a realist. The reality that I have experienced is that Cocoa Pods save considerable time and effort, especially when you have more than one framework included in your project. Cocoa Pods’ ability to deal with framework version control and framework dependency is brilliant and makes Cocoa Pods a must for EVERY project.

If you are still happy then… let’s get on with it.

You might think you need to do something special when creating the initial project. Nope.

You should definitely spend some time on the Cocoa Pods web site. It’s very well laid out and provides informative — not too technical — guides that show how to install and use Cocoa Pods.

Installing Cocoa Pods requires Terminal. If you are not comfortable using Terminal — I’ve provided a link at the end of the post to an excellent Terminal primer by Treehouse.

Open terminal and from your “home directory”, paste the following command.

sudo gem install cocoapods

Once you have entered your system password the Cocoa Pods GEM will install. The installation process will take a couple of minutes.

Once installation is complete you can check everything is good by entering this command into Terminal.

pod — version

Excellent. That’s this step completed.

There is so much going on in this chapter that we’ll dive straight into the video.

Creating a Podfile is a multi step process. Fortunately you only need to do this once for each project.

  • Launch TERMINAL and change directory to your Xcode project folder
  • Type the command pod init
  • Launch XCODE and open your project
  • Within XCODE select FILE > Add Files…
  • Add the podfile to your project — you will find this in your project directory
  • Update the podfile — adding your target Cocoa Pods
  • Close XCODE

There is a lot of tasks in that list. But it will be worth it. Especially when using frameworks that update several times a month.

What is a Podfile? A Podfile is a manifest or specification that tells Cocoa Pods exactly what Pods you want integrated into your Xcode project. The Podfile can detail specific versions and specific source locations for the target Pods. You can also detail different Pods for each of your project environments — like testing and run. If you are familiar with Ruby On Rails development — then a Podfile is nearly exactly the same as a Gemfile.

As ever — the best location for information about what you need to put in a Podfile is the Cocoa Pods web site.

Make sure you backup, duplicate or copy your project before you complete these actions.

It is this step that will implement your chosen frameworks into your Xcode project.

  • Launch TERMINAL and change directory to your Xcode project folder
  • Type the command pod install
  • Check Cocoa Pods has updated your project successfully
  • Check for dependency frameworks that might also have been added to your project
  • Notice the new file you will use to open your project in Xcode
  • Double-Click the new project file to open Xcode and your project
  • Check that your project still builds and runs

We need to remember that this post is not about HOW to develop using the Parse platform. So we’ll beg/steal/borrow from a previous project just to get something up and running.

If you want to learn how to begin developing using the Parse platform — check out my other posts.

Once you implement a Cocoa Pod it is very important that you follow and keep up to date with future releases of the Pod. The easiest way to do this is by signing up to the Pod email news letter.

If like me you receive hundreds of emails every day I recommend creating an email rule so that you can collect these update emails in one place.

It is a shame that the Cocoa Pods web site does not provide a subscription service — so you’ll likely have to deal with many efforts and teams.

Updating your Cocoa Pods is made super simple by the pod update command. Navigate to your Xcode project directory and enter the command pod update. This command validates all of the project Pods and updates those that have new releases — including managing any new or updated prerequisites.

Video to be added — once Parse update their Pod to 1.8.6!

That’s it. Congratulations — you’ve installed and implemented Cocoa Pods. Pat yourself on the back and think about what you’ll do with all your extra spare time. ;)


Originally published at on September 27, 2015.