Friday, March 29, 2013

Converted to Cocoapods

Went to an excellent Sydney CocoaHeads meeting last week where Mark Aufflick explained and demonstrated CocoaPods. I have now "seen the light" and am using them extensively.

Years ago, I used Perl as my scripting language of choice, the language was similar enough to C, had regular expressions built right in and didn't need a compile tool chain to run. The greatest thing about Perl wasn't the language but the amazing library of modules people had written to do just about anything, this library, called CPAN could be searched and installed from the command line.

CPAN has 119,767 modules, which is overwhelming but means that anything you need to do has probably been done and packaged up pretty well.

When I "saw the light" and moved to Python (thanks Alastair!), it eventually got a similar system called PyPi with just 29,430 packages. Then again, python has batteries included so there's a lot of stuff built right in.

CocoaPods is built on top of Git. There is a GitHub repository of specs that tell the tool where to get the files for each library. There are 1,277 pods so far. I won't reproduce the getting started guide here, but suffice to say, it's simple. You add a Podfile to your project directory and it brings in the source and adds it to your xcode project. Here's a Podfile for one of my projects:

platform :ios
pod 'MBProgressHUD', '~>0.6'
pod 'Facebook-iOS-SDK', '~>3.2'
pod 'FlurrySDK', '~>4.1'

The first thing I've noticed is that many of my projects had old versions of the Facebook, and Flurry SDKs and cocoaPods quickly fixed that.

I was worried about ending up with projects with external dependencies being left in our source code repository, but the solution to that is to add your Pods directory so the last source is always available even if the pod goes away in the future.

No comments: