Kotlin Multiplatform (KMM) is a modern powerful multiplatform development tool from JetBrains. This cross-platform SDK allows you to improve development by writing common code once and then reusing it across platforms. The level of code generalization depends only on the developer's desire: from general data models to full-fledged general business logic and even architecture, leaving the only UI on the side of native projects.
To organize a truly effective common code base, it is necessary to solve some seemingly trivial tasks, having their specifics and implementation features in a multiplatform application. One of these tasks is organizing and configuring connections between application components via DI while maintaining operability and correctness not only on Android but also on iOS. Platform implementations are quite nuanced, and hidden pitfalls can disrupt structure and relationships in the overall code base of a KMM application.
In this talk, Anna wants to consider the main cases of how you can organize work with DI in the KMM application:
- what platform nuances should be considered;
- how suitable native solutions are for this;
- how effective and convenient are the existing DI solutions in the general KMM code and are they suitable for both mobile platforms (iOS and Android);
- organization of DI in a common code base of a KMM application without third-party solutions (implementation option).
We'll also look at some practical examples to illustrate.