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

Micro Frameworks: What, why and how?

Micro Frameworks: What, why and how?

Based on Tuist.io I worked with a large codebase to switch from a large monolith app target to over an app with over 20 frameworks. This has improved the work of all involved by dramatically reducing compile time, merge conflicts and developer productivity in general.

Video of this presentation at NSSpain: https://vimeo.com/646341988/ce3af3675c?embedded=true&source=video_title&owner=32858286

Jeroen Leenarts (AppForce1)

November 18, 2021
Tweet

More Decks by Jeroen Leenarts (AppForce1)

Other Decks in Programming

Transcript

  1. About me • Software developer since 2002, iOS since SDK

    v. 3 • Worked on several apps B2C, B2B • ING Banking, Nyon, Achmea, SurfNet, Multiple small apps • CocoaHeadsNL apps • Team lead role 2018  2021 • Wrote a book based on my experience • Since November 2021 Developer Relations Engineer iOS at Stream 2/29
  2. Topics • What? • Micro/feature frameworks and apps • Why?

    • Compile time • Reflect team structure and responsibilities • How? • Using Frameworks • Many targets 5/29
  3. What are Micro Frameworks and Feature Frameworks? First of all,

    is there a difference? I think it is interchangeable and mostly depends on what you are comfortable with. It is a way of thinking and structuring your project. Based on the concept of microservices. 6/29
  4. A Micro Feature is composed of several Frameworks You split

    your implementation in a way that makes sense to you. Each feature could be implemented by these frameworks: • Source • Interface • Tests • Testing • Example 7/29
  5. A Micro Feature is composed of several Frameworks FeatureExample Feature

    FeatureTesting FeatureInterface FeatureTests 8/29
  6. Why split up your codebase in Frameworks? • Compile time

    • Separation of concerns, battle scaling issues • Allows for defining API levels and boundaries 10/29
  7. Compile time • Let's be honest. • You also define

    way to much as being public or have default scope 11/29
  8. Compile time • Many codebases is one big pile of

    sourcecode • When compiling, all your code and dependencies are in scope during compilation and linking • Lots and lots of work 12/29
  9. Compile time • Creating frameworks decreases the amount of code

    that can "see" each other during compilation. • Provided you put some constraints in place. • Default scope helps you here, since it is package private • Just creating and properly scoping your Frameworks potentially cuts your compile time in half. If not more. No joke. 13/29
  10. Separation of concerns, battle scaling issues Having scaling issues within

    a codebase/project is a good thing • But how do you reflect team boundaries in you code? • How to separate features in your code? With Frameworks ! 14/29
  11. Allows for defining API levels and boundaries You can also

    use Frameworks to clearly define API levels and boundaries • Besides features, create frameworks for • networking • authentication • storage • etc. • Easy encapsulation and isolation of 3rd party dependencies 15/29
  12. Allows for defining API levels and boundaries • When using

    frameworks scope becomes much more useful • Code level API documentation integrated very well in Xcode. • Easy caching and pre-building of parts of the entire codebase 16/29
  13. How to work with Frameworks? Did you ever create a

    Framework in Xcode manually? It takes some effort right? 17/29
  14. How to work with Frameworks? Creating Frameworks manually is very

    tedious and error prone. How to - do it right - keep things consistent - make sure it is easy to create additional Frameworks? 18/29
  15. How to work with Frameworks? This is where Tuist comes

    in. • CLI • Generates Xcode projects • Define you project structure and settings in Swift • No more Xcode project file conflicts, ever. 19/29
  16. Demo Do you remember this picture? Application µSearch µHome µProfile

    µFeatures µCore µUI µTesting Let's see how this looks in Tuist. 21/29
  17. Combining everything • We talked about • Feature Framework clusters

    • Feature composition But each feature is composed of several Feature Framework specific Targets • Source, Interface, Tests, Testing, Example 22/29
  18. Demo Remember these two? Let's combine these two… FeatureExample Feature

    FeatureTesting FeatureInterface FeatureTests Application µSearch µHome µProfile µFeatures µCore µUI µTesting This should result in 30 targets. 23/29
  19. How to create consistency? • Templates and abstraction • This

    is where all of your Swift skills come in 24/29
  20. What about Bazel or Buck? Both are great tools. But

    they are also complex. Tuist fills the gap between straight forward Xcode projects and having budget to create dedicated teams to support your builds. I have looked at all three. Tuist has the deepest and best integration with tools surrounding Apple's Xcode IDE. 26/29
  21. Stream supports Tuist We at Stream think Tuist is a

    great idea. We now sponsor the ongoing development of Tuist. Check them out, learn about their approach, unlock true scaling of your Xcode based codebase. 27/29