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

Modular iOS App @ UIKonf 2014

Modular iOS App @ UIKonf 2014

Given at the UIKonf 2014 in Berlin.

Piet Brauer

May 15, 2014
Tweet

More Decks by Piet Brauer

Other Decks in Programming

Transcript

  1. Modular iOS Apps
    Piet Brauer
    XING AG

    View Slide

  2. Architecture should be about enabling small
    teams to work on small components
    » Mike Hadlow

    View Slide

  3. Should you care about
    modules?
    YES, If you ...

    View Slide

  4. ... maintain multiple apps

    View Slide

  5. ... develop white-label apps
    with core code bases

    View Slide

  6. ... have a large code base

    View Slide

  7. How?
    Multiple approaches

    View Slide

  8. Facebook
    Uses ...
    » ... one large work space
    » ... static libraries and bundles
    » ... xcconfig files
    » ... FBFoundation, FBUIKit, FBDataModel, FBAppKit
    » ... Modules register via module manager
    » ... URL schemes to navigate
    Modules @ Facebook

    View Slide

  9. PSPDFKit
    Uses ...
    » ... Dependency Injection
    » ... a Plugin Infrastructure
    » ... Aspect oriented programming
    » ... URL schemes to navigate (with JLRoutes)
    Aspect by Steipete
    Slides from ITT

    View Slide

  10. XING
    (Will) Use(s) ...
    » ... multiple independent projects
    » ... CocoaPods to link them
    » ... XNGFoundation, XNGUIKit, XNGDataModel, etc.
    » ... domain specific modules
    » ... a module manager
    » ... URL schemes to navigate

    View Slide

  11. What does a Module
    Manager do?

    View Slide

  12. Current

    View Slide

  13. Near Future

    View Slide

  14. Tools

    View Slide

  15. CocoaPods
    » 2 Specs repositories
    » 20+ internal Pods
    » our own pod template

    View Slide

  16. Versioneye
    » ... monitors your projects
    » ... monitors open source libraries
    » ... notifies you if a new update was released
    » ... draws a beautiful dependency graph

    View Slide

  17. Rake tasks
    » Rake is to Ruby what Make is to C
    » easy to write scripts
    Sample
    rake bootstrap # Installs dependencies
    rake ci # Runs everything needed for the ci server
    rake deploy # Deploys Beta
    rake release # Release a new version of the Pod
    rake spec # Runs the specs

    View Slide

  18. Pull Requests work flow
    » each developer works on his own fork
    » when he is done he makes Pull Requests
    » Jenkins builds them and gives feedback
    » another team mate reviews the code and merges
    » reviewer decides what version number to pick and
    releases

    View Slide

  19. Travis || Jenkins

    View Slide

  20. How we use Jenkins
    Jenkins ...
    » ... is triggered on every git commit
    » ... runs the unit tests
    » ... sets the build status on the commit in Github

    View Slide

  21. Developer Sandboxes

    View Slide

  22. How to create a new pod?
    » pod lib create UIKonf
    » rake bootstrap

    View Slide

  23. View Slide

  24. Generated project
    !"" Assets
    !"" CHANGELOG.md
    !"" Classes
    !"" Example
    # !"" Assets
    # !"" Example
    # !"" Example.xcodeproj
    # !"" Podfile
    # !"" Podfile.lock
    # $"" UnitTests
    !"" Gemfile
    !"" Gemfile.lock
    !"" LICENSE
    !"" README.md
    !"" Rakefile
    !"" UIKonf.podspec
    $"" UIKonf.xcworkspace

    View Slide

  25. Development pods
    pod 'UIKonf', :path => '../UIKonf.podspec'
    » does not copy source files
    » work as if the files are in your project
    » see immediately if something is not public

    View Slide

  26. Demo

    View Slide

  27. Pitfalls & Solutions

    View Slide

  28. Semantic Versioning
    Is a pain because ...
    » ... we want every team to use a latest version
    » ... dependent pods
    » ... informing other teams about updates is time
    consuming
    » ... you never know what you break exactly

    View Slide

  29. Semantic Versioning
    Why resolve the dependencies?
    » see which pods depend on one
    » see unnecessary dependencies

    View Slide

  30. Semantic Versioning
    Now works for us because ...
    » ... Versioneye tracks new versions and informs
    » ... we don't pin the version in podspecs anymore
    » ... Jenkins builds all projects that depend on the
    changed pod

    View Slide

  31. Data Model
    Is a pain because ...
    » ... it is one CoreData file
    » ... all pods somehow depend on it

    View Slide

  32. Data Model
    Now works for us because ...
    » ... it only contains mogenerator generated files

    View Slide

  33. Jenkins
    Was a pain because ...
    » ... it cannot build forks
    » ... setting it up takes time

    View Slide

  34. Jenkins
    Now works for us because ...
    » ... each pod has the same Rakefile
    » ... all we need to execute is rake ci

    View Slide

  35. Localized Strings
    Was a pain because ...
    » ... Localization was spread across pods
    » ... you couldn't track duplicates
    » ... changes were hard

    View Slide

  36. Localized Strings
    Now works for us because ...
    » one pod containing all translations
    » will be maintained by translators
    » People make Pull Requests with their translations

    View Slide

  37. Images
    Was a pain because ...
    » ... there were duplicates across the pods
    » ... changes were hard
    » ... 2 images with the same name could occur

    View Slide

  38. Images
    Now work for us because ...
    » ... resource bundle feature in CocoaPods
    » ... we load them from a bundle
    » .. no conflicts in naming because of bundles

    View Slide

  39. Thanks!!
    xing.to/PietBrauer && https://twitter.com/pietbrauer
    Like the modules idea? We are looking for you!
    https://xing.com/ios

    View Slide

  40. Resources
    » https://www.youtube.com/watch?v=OJ94KqmsxiI
    » https://github.com/steipete/Aspects
    » https://speakerdeck.com/steipete/architecting-
    modular-codebases
    » http://jenkins-ci.org/
    » https://travis-ci.org/
    » https://www.versioneye.com/

    View Slide

  41. Images
    * Jenktocat, https://octodex.github.com/images/jenktocat.jpg
    * Johann Lafer - Rezepte aus meiner Heimat, https://itunes.apple.com/de/app/johann-lafer-rezepte-aus-meiner/id505874478?mt=8
    * Sommerrezepte - Die besten Rezepte für die Urlaubssehnsucht, https://itunes.apple.com/de/app/sommerrezepte-die-besten-rezepte/id680597527?mt=8
    * Schlank im Schlaf - Die original Rezepte, https://itunes.apple.com/de/app/schlank-im-schlaf-die-original/id584432534?mt=8
    * Jenkins, http://fabiouechi.blogspot.de/2012/11/setting-up-jenkins-on-ec2-using.html
    * Travis CI, http://jmikola.github.io/slides/beautiful_measurable_software/img/travis-mascot-600px.png

    View Slide