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

Prepare your project for KMM

Prepare your project for KMM

Kotlin Multiplatform is not yet stable. Despite this, many companies have taken the leap of faith and have started adopting it in their production projects.

In this session, we will see an overview about KMM (Kotlin Multiplatform Mobile) and how to prepare your project to adopt it.

A deep look at the modularization architecture and how it facilitates sharing the maximum layers between the different stacks.

We will make the focus on Android and iOS, specially coming from native projects. We will explain how to migrate your project in order to integrate it with a KMM module. Lastly, we can not forget that we can use the shared modules on Desktop and Web Apps.

Will you take the leap of faith?

oussama ben wafi

September 24, 2022
Tweet

More Decks by oussama ben wafi

Other Decks in Technology

Transcript

  1. @oussamto • KMM not already stable, things may change •

    Architecture still subjective topic 😉 Disclaimer
  2. @oussamto 5 • KMM overview • How? application in from

    scratch project • How? existing project (monolithic,Modular…) • Implementation • KMM Librairies What to expect
  3. Shared Module (platform-specific)? expect class Platform() { val platform: String

    } actual class Platform actual constructor () { actual val platform: String = "Android ${android.os.Build.VERSION. SDK_INT}" } actual class Platform actual constructor () { actual val platform: String = UIDevice. currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion } commonMain androidMain iosMain
  4. From Scratch Project Android App iOS App Shared module ViewModel

    Jetpack Compose ViewModel SwiftUI UseCase UseCase Repository Repository LocalDataSource RemoteDataSource ApiService Database
  5. Basic-Modular app • Domain can go shared • Data looks

    monolothic, we can find a many dependencies • Core looks monolithic, coreDesign, data-network data domain UI core
  6. Modular by feature app app data-Network shared data-database shared PaymentShared

    data domain PaymentUI DashboardShared data domain DashboardUI Shared Core
  7. What to share? Jetpack Compose SwiftUI ViewModel ViewModel UseCase Repository

    RemoteData Source LocalDataSo urce ApiService Retrofit Alamofire Database Room Realm Ktor SqlDelight
  8. Modularization Benefits 1. Faster 2. Good For business 3. Easy

    and scalable development 4. New technology experiment 5. Simple and easy to test
  9. Android app dependencies dependencies { implementation project(path: ':homeUi') implementation project(path:

    ':shared') implementation project(path: ':data-network-shared') • Separate the UI Module • Make Domain and Data module into shared module • Extract data-networking into shared module
  10. iOS dependencies iOS app will depends on shared module which

    includes • shared-core • data-network-shared
  11. @oussamto Most useful libraries • xcode-kotlin: Xcode plugin for Kotlin

    debugging and source formatting • Ktor: Client/Server networking • Kotlinx.Coroutines: Support library for coroutines. • Kotlinx.Serialization: Complete multiplatform support: JVM, JS and Native. • SqlDelight: Multiplatform SQLite model facilitation library.
  12. @oussamto Kermit the log Kermit is a Kotlin Multiplatform logging

    utility with composable log outputs. Out of the box, the library defaults to platform-specific loggers such as Logcat and OSLog, but is easy to extend and configure. Logging