![]() This module seemed like a good start because it had the least amount of external dependencies. Domain and Data layerĪt first, I stared with the Domain and Data layer of the stopwatch module. This allowed me to use Hilt in the Android app, but still retrieve the KMP dependencies from Koin.Īfter the core module I focused on moving the feature modules which contained all the layers (Presentation, Domain, Data and UI which I didn't move). In order to make the process straightforward without a lot of changes, I marked the Hilt module as a KoinComponent and used Koin to retrieve the dependencies: TimestampModule: KoinComponent fun provideTimestampProvider(): TimestampProvider = get() The problem came with Dependency Injection, the Android app used Dagger Hilt for DI, but for Kotlin Multiplatform I wanted to use Koin. ![]() Fortunately, the module didn't contain any Java specific libraries, so it was easy to move it to KMP. ![]() This module contains interfaces and data structures which are used in many of the other modules. The core moduleĪt the start, I focused on the "core" module of the application. The Android codebase was modularized, which allowed me to move the logic to KMP on a module by module basis. Keep in mind that the project is pretty small, which allowed me to do the refactor in much bigger steps without fear of breaking something. Moving existing logic to Kotlin Multiplatform The first KMP integration was done o Android, and then I got it working on iOS.Īfter these steps, I had a working bare-bones Kotlin Multiplatform app which shares some code with both platforms.The next step was copying over the playground KMP module and the iOS project into the Timi codebase.In the Timi codebase, I did some gradle related clean up to make Kotlin Multiplatform integration easier (replaced Groovy with Kotlin DSL and added refreshVersions for dependency version management).I used this class on both Android and iOS to see if everything works. I removed everything I didn't need and added a simple class resembling one feature of Timi (A stopwatch). My first step was creating a new playground project based on the KaMPKit starter.Adding Kotlin Multiplatform and iOS to the codebase The modularization used for this project is explained more in-depth in my Modularizing a Kotlin Multiplatform Mobile Project. If you're interested in the commits of this process, they're available in the GitHub repository (starting from the 2022 commits). In this article, I'll share my experience making a Kotlin Multiplatform app from an Android only codebase. Working on a smaller project also allows for more experiments, in this project I'll try to share as much code as possible, and see how that integrates on both mobile platforms. This time my focus is on learning the iOS side of Kotlin Multiplatform, I'm hoping that this experience will help me better understand my colleagues on the other platform. Recently I reactivated my old project Timi which I used to learn Compose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |