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

Pods to the rescue

Pods to the rescue

This talk describes how to use CocoaPods for the modularisation of your own application by creating private pods and a private specs repository.

Michael Ochs

July 20, 2015

More Decks by Michael Ochs

Other Decks in Programming


  1. Pods to the rescue • Benefits of modularisation • CocoaPods

    • Creating a pod • The specs repository
  2. Benefits of modularisation • Less code to maintain (per module)

    • Less dependencies • Explicitely declared dependencies • Well defined interface • You can’t be lazy anymore Better maintainability
  3. Benefits of modularisation • Managing dependencies is a nightmare •

    Multiple modules might have the same dependency • Different modules use different versions of their dependencies • Updating one module requires all dependant modules to update The downside of all of this
  4. CocoaPods • Adds the source code of AFNetworking • Adds

    all resources of AFNetworking • Adds all dependencies of AFNetworking • Configures your Xcode project The Podfile
  5. CocoaPods • Updates the source code of AFNetworking • Updates

    all resources of AFNetworking • Updates all dependencies of AFNetworking • Configures your Xcode project The Podfile
  6. CocoaPods • Contains all dependencies a pod has • other

    pods, libraries, frameworks • Contains the list of public files and resources • Contains the path to the pod and other meta data • version, description, author,… The .podspec
  7. Creating a pod • A pod contains a <YourPod>.podspec file

    • Contains all the meta data that is necessary • May contain a demo and a test target > pod lib create <YourPod> Essential parts
  8. Semantic Versioning • Dependency management through version numbers • All

    modules follow the same versioning concept • Great to be used for frameworks and libraries • Not for marketing or application versioning
  9. Semantic Versioning • Used for backwards compatible bug fixes •

    No new public API • Internal API may change • Fixes internal misbehaviour MAJOR.MINOR.PATCH
  10. Semantic Versioning • Introduces new features or new public API

    • Introduces deprecations in the public API • May introduce substential internal changes • May contain patch level changes • Patch version must be reset to 0 MAJOR.MINOR.PATCH
  11. Semantic Versioning • Introduces backwards incompatible changes to the public

    API • May contain minor and patch level changes • Minor and patch version must be reset to 0 MAJOR.MINOR.PATCH
  12. Semantic Versioning • 0.x.x is a special major version •

    Public api is considered unstable at any time • Used during initial development Version 0.x.x
  13. Semantic Versioning • Development starts with 0.1.0 • New features

    and removed public API: 0.2.0 • Bugfix release: 0.2.1 • First stable version: 1.0.0 • Public method is deprecated: 1.1.0 • New features: 1.2.0 • Bugfix release: 1.2.1 • New version that removes previously deprecated methods: 2.0.0 Example
  14. Semantic Versioning • Modules depend on another modules major version

    • Minor and patch are just used to get the minimum version • Automatically upgrade to all minor and patch versions Dependency management
  15. The specs repository • A git containing all .podspec files

    from the supported pods • Used by pod install and pod update • Referenced in the Podfile via the source keyword
  16. The specs repository • Create a private specs repository for

    your own modules • Company wide Private
  17. The specs repository • Create an empty git repository >

    pod repo add REPO_NAME REPO_URL > pod repo push REPO_NAME SPEC_NAME.podspec • Add source ‘REPO_URL’ to Podfile Private
  18. The specs repository • Do not fork the master specs

    repository • Prefix your private pods Private