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

Wallapop as? Lego

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Wallapop as? Lego

Static libraries... Dynamic Frameworks... We may have a guide about how to build our app modules but, in the end, we always end up with something like a Lego monster, don't we? At Wallapop, we work on a large Swift + Objective-C codebase that's been living for 6 years now, with 9 iOS developers, you can imagine the kind of headache this might be. Come and see how we're putting all the blocks together.

Avatar for Wallapop Eng

Wallapop Eng

May 23, 2019

More Decks by Wallapop Eng

Other Decks in Programming

Transcript

  1. iOS Team Links at start time Less app size Static

    library vs dynamic framework Static Dynamic Links at compile time Bigger app size Slower start time Faster start time Imported needs recompiling No need for recompile
  2. iOS Team - It’s a .pbxproj, compiled as static library

    - It can be horizontal (Divided in layers) - It can be vertical (Divided in features) A module for us is…
  3. iOS Team Clue: It’s not for fun… at least in

    part… Why do we modularize? - Compiler limit error - wallapop becoming a huge target - Many other advantages…
  4. iOS Team Sample projects Show me the advantages! Improve compilation

    times Fix CI errors Code encapsulation Make clean interfaces AVOID DEVELOPER NIGHTMARES
  5. iOS Team * This image may not represent yet the

    actual status of the wallapop iOS Dev team
  6. iOS Team Our module interface rules No third party libraries

    Know other modules Lightweight No resources Development pod Protocols No implementation ⛔
  7. iOS Team Interface example public protocol ChatInterface { func showInbox()

    func existsConversation(_ id: String) -> Bool func createConversation(userId: String, itemId: String) }
  8. iOS Team Our module project rules CocoaPods Third party ⛔

    Other project No resources Workspace project Public implementation Only knows interfaces Test
  9. iOS Team Module structure Source code Unit test Snapshot test

    Example project Other module interfaces Development pods Third party
  10. iOS Team Legacy interface to the rescue - It’s a

    development pod - Follows the same module interface rules - Easy to mock
  11. iOS Team Modules interfaces Chat Shipping Ads PROs wallapop as!

    Lego Discovery Storage Realtime API Client Legacy Dependency injection Third party libraries Modules Responsibility Development pods Dependencies Main App
  12. iOS Team There’s a popular library - Swinject - More

    than 3000 stars on GitHub - No code generation required
  13. iOS Team How does it work? let dependencyContainer = DependencyContainer()

    dependencyContainer.register(ItemInterface.self, dependency: Item()) dependencyContainer.resolve(ItemInterface.self).resolve()
  14. iOS Team How does it work? let dependencyContainer = DependencyContainer()

    dependencyContainer.register(ItemInterface.self, dependency: Item()) dependencyContainer.resolve(ItemInterface.self).resolve()
  15. iOS Team How does it work? let dependencyContainer = DependencyContainer()

    dependencyContainer.register(ItemInterface.self, dependency: Item()) dependencyContainer.resolve(ItemInterface.self).resolve()
  16. iOS Team - Resolve dependency inside a closure How did

    we solve it? - Force unwrap as a compromise
  17. iOS Team Mocked dependencies - Generated using Sourcery - Avoids

    having to mock dependencies manually in each example app - Used for example apps
  18. iOS Team Generated using Sourcery - Code generation tool for

    Swift - Built on top of SourceKit - github.com/krzysztofzablocki/Sourcery