Skip to content

KMP Migration Guide

Sk Niyaj Ali edited this page Jan 7, 2025 · 1 revision

Kotlin Multiplatform (KMP) Migration Guide

Prerequisites and Important Notes

Before starting the migration process, please note:

  • Module dependencies must be migrated in the correct order
  • Feature modules should not depend on other feature modules
  • Core module access rules:
    • Data modules can only access database and network modules
    • Network module can access datastore but not database
    • Domain module can only access data, common, and model modules (no direct access to network or database)

Migration Process

Step-by-Step Migration Instructions

  1. Initial Setup

    • Apply the plugin and sync the project
    • Apply Platform or Common dependencies to the target module
    • Create commonMain directory and add package structure
    • Move all files from main directory to commonMain
  2. Code Migration

    • Refactor and fix imports in each file
    • Migrate from Hilt DI to Koin DI Module
    • Create actual/expect declarations for platform-specific implementations
  3. Code Quality Checks

    • Run Spotless (e.g., ./gradlew :core:model:spotlessApply)
    • Run Detekt (e.g., ./gradlew :core:model:detekt)
    • Review all changes thoroughly before committing

Migration Order Reference

Core Modules

  1. :core:model
  2. :core:common
  3. :core:datastore
  4. :core:network
  5. :core:designsystem (with CMP)
  6. :core:ui (with CMP)

Libraries

Feature Modules

  1. Authentication & Security

  2. Main Features

  3. Financial Features

  4. Transfer & Payment Features

  5. Additional Features

Final Steps

  1. Perform final cleanup
  2. Set up iOS application

Reference Commits

Initial setup and key migrations:

Post-Migration Checklist

  1. Verify all modules have been migrated correctly
  2. Ensure all tests pass
  3. Check platform-specific implementations
  4. Review dependency graph
  5. Create pull request for review

Remember to consult the official architecture guide for additional information and best practices.