Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using CocoaPods for Objective-C Library Management

Using CocoaPods for Objective-C Library Management

Presented at OSDC.tw 2013

Richard Lee

April 20, 2013
Tweet

More Decks by Richard Lee

Other Decks in Technology

Transcript

  1. Using CocoaPods for
    Objective-C Library Management
    Richard Lee
    Polydice, Inc.

    View full-size slide

  2. iOS Dev Since 2010
    Richard Lee
    @dlackty everywhere

    View full-size slide

  3. Who know this?

    View full-size slide

  4. Three20
    •UI collections & utilities for iOS
    •Derived from old Facebook for iPhone
    •#1 starred Objective-C project on GitHub
    •Where I started my journey to OSS
    •Abandoned project for around a year though
    •Also, Three20 is notorious for...

    View full-size slide

  5. It is so hard to add Three20
    to my project .

    View full-size slide

  6. Cocoa library installation
    Install Cocoa library is hard because
    •Library / framework dependencies
    •Automatic reference counting v.s. non-ARC
    •Header files import dependencies
    •Compiler choices (gcc / gcc-llvm / clang)
    •Xcode / iOS version differences

    View full-size slide

  7. UIViewController
    NSArray
    TTNavigator
    FBGraphObject
    PSTCollectionView
    AFNetworkOperationQueue
    Even worse,
    there is no namespace
    in Objective-C

    View full-size slide

  8. CocoaPods’s goals
    •Make working with dependencies simple
    •Improve library discoverability and engagement

    View full-size slide

  9. Podfile lists the dependencies of your app
    How CocoaPods works?
    Podfile.lock locks the versions of pods
    Podspec contains specs of pods
    Pod represents a Cocoa library

    View full-size slide

  10. Start using CocoaPods today!
    Create your Podfile
    Install dependencies
    Install CocoaPods
    Then you’re ready to go!

    View full-size slide

  11. Install CocoaPods:
    $ [sudo] gem install cocoapods
    $ pod setup

    View full-size slide

  12. Sample Podfile
    platform :ios, :deployment_target => '5.0'
    pod 'Nimbus/Core'
    pod 'Nimbus/NetworkControllers'
    pod 'Nimbus/WebController'
    pod 'AFNetworking'
    pod 'BlocksKit', '=1.5.2'
    pod 'SSPullToRefresh', '>=1.0.0'
    pod 'SDURLCache'
    pod 'Facebook-iOS-SDK'
    pod 'iCookSDK', :git => "git@..."

    View full-size slide

  13. Install dependencies:
    $ pod install

    View full-size slide

  14. Open app.xcworkspace
    and everything is done!

    View full-size slide

  15. Nice! But...what if, there’re no
    Podfile available for my desired
    library?

    View full-size slide

  16. Create Podspec
    Podspec describes library’s
    •Basic infos (Name / Description / Version)
    •Where to download? (Mostly Git)
    •Copyright info (Author and license)
    •Source files / Header files / Resource files
    •Compile settings
    •Library dependencies

    View full-size slide

  17. Create Podspec:
    $ pod spec create OSDCView
    Lint Podspec:
    $ pod spec lint OSDCView

    View full-size slide

  18. CocoaPods’s goals
    •Make working with dependencies simple
    •Improve library discoverability and engagement

    View full-size slide

  19. Find Pods from
    CocoaPods.org

    View full-size slide

  20. Find Docs from
    CocoaDocs.org

    View full-size slide

  21. Find UIs from
    CocoaControls.com

    View full-size slide

  22. You can be part of us!
    The app universe need your help!
    •Release open source libraries
    •Write Podspec for others
    •Maintain current Podspecs
    Just send pull requests to CocoaPods repos!

    View full-size slide

  23. Thank you for listening!

    View full-size slide