CocoaPods

Sane library management for Xcode


leonard.ehrenfried@gmail.com

github.com/lenniboy


So, you're starting a new Xcode project

  • Look for some libraries to use in your project
  • Maybe an OAuth ibrary?
  • How to import it into your project?

Installation instructions

  1. drag the OAuth2Client.xcodeproj into your project
  2. add OAuth2Client as a build dependency
  3. add OAuth2Client/** to your user header search path in the build settings
  4. link your target against OAuth2Client (drag the OAuth2Client product from OAuth2Client.xcodeproj to your targets Link Binary With Libraries)
  5. #import "NXOAuth2.h"

Why is manual installation problematic?

  • Error-prone
  • Upgrade path unclear
  • No transitive dependencies


Worst of all?

The library source is supposed to be added to version control!

Other languages and platforms have automated all of this

Python has easy_install/pip

Ruby has gem

JavaScript has npm

Java has Maven

Objective-C has ?

Enter Cocoapods

  • Library dependency management for Xcode projects
  • Community maintained
  • Written in Ruby
  • Modelled after Rubygems
  • gem install cocoapods

Great, how does it work?

  1. Create an Xcode project
  2. Add a Podfile to your project folder
  3. Add your dependency to it
  4. pod install
  5. Compiles your library dependency as a static library
  6. Takes your project and puts it into an Xcode workspace
  7. Adds static library to workspace
  8. You open App.xcworkspace instead of App.xcproject
  9. Profit!!1!

Demo Time

MBProgressHUD

Anatomy of a podspec

              
Pod::Spec.new do |s|
  s.name     = 'MBProgressHUD'
  s.version  = '0.5'
  s.platform = :ios
  s.license  = 'MIT'
  s.summary  = 'An iOS activity indicator view.'
  s.homepage = 'https://github.com/matej/MBProgressHUD'
  s.author   = { 'Matej Bukovinski' => 'matej@bukovinski.com',
                 'Jonathan George'  => 'jonathan@jdg.net' }

  s.source   = { :git => 'https://github.com/jdg/MBProgressHUD.git', :tag => '0.5' }

  s.source_files = '*.{h,m}'

  s.framework    = "CoreGraphics"
end
            
            

In-house development

Referencing a local folder in a podspec

Host your own repository of podspecs

Random feature overview

Last night: 589 pods

Contributing is easy, just fork and create a pull request

Handles difference between ARC and non-ARC dependencies

:test/:dev scopes available

iOS and OSX dependencies

THE END

Questions?


cocoapods.org