CocoaPods Saves Lives

I wonder how many iOS developers have had to link external code into their project and thought “I would rather eat glass”. Importing code from other sources has been annoyingly inconvenient; if you were really lucky, someone bundled their work into a Framework or static library and you gracefully link it into your project. In my experience though, its more frequent that you’re going to be dealing with either a full-blown project, or a handful of source files. This is “fine” but it comes with baggage:

You get the picture. A developer’s tools should never get in the way of the primary job: writing good software. In fact, the mantra should be the inverse:

A developer should only adopt a tool if it lets them write better software.

Gem Envy

A few days ago I attended the local iPhone Developer Meetup to learn more about CocoaPods. I’d previously heard it described as RubyGems for iOS, and that makes sense given that its actually written in Ruby. I’ve always had a bit of envy for the Ruby crowd for the syntax, but the gems library/dependencies system is pretty damn sweet too.

After Jeff Friesen’s presentation, I was sold. CocoaPods is a lot like RubyGems, and its a refreshingly simple approach to handling code imports to your iOS project.

How Simple?

There are three steps to getting CocoaPods running on your project:

  1. Install CocoaPods - if you’ve got Ruby on your system (and its available through the Xcode command-line tools installation), all you need to do is run: sudo gem install CocoaPods
  2. Write A Podfile - just like a gemfile, and the syntax is almost identical, its a list of the code imports you want in your project and their respective versions
  3. Import The Pods - once you’ve got your Podfile written up, all thats left is to run the command that fetches the code (in “pods”) and integrates them into your Xcode project automagically: pod install

That simple.

Naturally the code you’re wanting to import has to be found in the pods-spec repository, but that repo is growing really quickly, and contributing to the CocoaPods repo is pretty straightforward.

My experience with CocoaPods thus far has been nothing short of fantastic and I’m looking forward to contributing to the community. Its been solving the three workflow problems I described above, getting the manual dependency management time-sinks out of my way so I can focus on my real work.

Kudos to the @CocoaPods team for this fantastic tool.