> Markdown version of [/videos/276-introducing-kotlin-multiplatform-in-an-existing-project?t=35](https://www.wearedevelopers.com/videos/276-introducing-kotlin-multiplatform-in-an-existing-project?t=35). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Introducing Kotlin Multiplatform in an existing project Tired of writing the same mobile business logic twice? Learn how to gradually introduce Kotlin Multiplatform into your existing codebase, sharing non-UI code without a risky rewrite. - **Speakers:** Marco Gomiero - **Event:** WeAreDevelopers LIVE - **Published:** November 3, 2021 - **Duration:** 47:37 - **URL:** https://www.wearedevelopers.com/videos/276-introducing-kotlin-multiplatform-in-an-existing-project ## Summary Introducing Kotlin Multiplatform (KMP) into a legacy or existing mobile project requires shifting from a standard monorepo structure to a modular library approach. Unlike traditional cross-platform frameworks that attempt to unify UI systems, KMP focuses solely on sharing non-UI business logic—creating a single source of truth while preserving native architectural freedom and performance across Android and iOS. This pragmatic separation dictates that existing codebases slowly adapt by extracting small, self-contained features rather than attempting an aggressive rewrite. The technical transition heavily involves dependency management and distribution configuration. On the Android side, Gradle publishes a compiled AAR directly to a Maven repository, allowing the primary application to consume the shared code natively. For iOS, integration demands more orchestration since the Apple ecosystem does not natively communicate with Gradle. Teams must configure Gradle automation tasks to build an XCFramework—which bundles architecture binaries for both physical devices and simulators—and distribute it via CocoaPods. Adopting KMP also surfaces unique concurrency rules in Kotlin Native, historically necessitating explicit object immutability through a `freeze()` function when sharing data between threads, a requirement that newer Kotlin memory models aim to gracefully deprecate. Successful KMP adoption hinges on a gradual, calculated rollout to validate integration pipelines without risking significant development time. Engineering teams should start by sharing "code that is boring to write twice," such as data transfer objects (DTOs), utility classes, and analytics layers, before expanding into more complex targets utilizing libraries like SQLDelight. Crucially, enforcing a shared architecture must be a collaborative, cross-functional effort between both Android and iOS developers. Establishing unified testing methodologies and collective bug-squashing prevents friction, ensuring the migration truly benefits the entire organization by eliminating redundant implementation cycles. **Keywords:** kotlin multiplatform migration, shared business logic extraction, cross-platform mobile development, ios framework distribution, xcframework integration, cocoapods dependency management, maven repository publishing, gradle automation tasks, sqldelight database layer, kotlin native concurrency, monorepo project structure, dto extraction strategy, platform-specific ui testing, mobile continuous integration ## Chapters 1. **How Kotlin Multiplatform differs from cross-platform frameworks** (00:35) — KMP allows teams to share generic business logic layers instead of imposing a unified interface layer. 1. **Creating new Kotlin Multiplatform mobile application projects** (03:30) — The official Android Studio plugin provides necessary scaffolding to instantly generate correctly structured cross-platform repositories. 1. **Structuring KMP adoption in existing native projects** (09:35) — Deploying shared modules as independent external libraries circumvents the heavy refactoring required for monolithic architecture conversions. 1. **Scaffolding a standalone KMP shared logic library** (13:39) — A dedicated repository built in IntelliJ natively supports compilation into distinct AAR binaries and iOS frameworks. 1. **Publishing the shared logic library for Android** (15:35) — The Maven publish plugin handles routing the compiled JVM artifacts directly into local or external Android dependency managers. 1. **Packaging and distributing the iOS XCFramework bundle** (17:17) — Bundling device and simulator architectures into one target allows Cocoapods to seamlessly integrate dependencies for Xcode builds. 1. **Automating framework distribution workflows with Gradle tasks** (25:21) — Custom Gradle scripts automate checking out remote branches, compiling correct framework instances, and committing versioned podspec configurations. 1. **Handling thread concurrency and memory in Native** (28:04) — Legacy Kotlin Native models dictate that passing code references across threads requires explicit object freezing to enforce immutability. 1. **Validating infrastructure pipelines before extracting critical features** (31:38) — Migrating simple structural contracts like DTOs proves repository workflows safely function before introducing complex system extractions. 1. **Navigating concurrency limits and initial build setup** (36:28) — Advanced asynchronous concurrency paradigms and fragile Gradle dependencies remain the primary sources of initial implementation friction. 1. **Overcoming toolchain adoption friction for iOS teams** (37:56) — Aligning interdisciplinary teams ensures collaborative feature ownership rather than merely pushing native iOS processes into foreign ecosystem tooling. 1. **Evaluating cross-platform suitability based on hardware dependencies** (40:13) — Certain low-level operating components like bluetooth connectivity are better preserved as pure implementations isolated from core shared module deployments. 1. **Distinguishing Compose Multiplatform from native SwiftUI frameworks** (44:00) — Skia rendering approaches differ fundamentally from platform-abstracted wrapper libraries that leverage pure native interface elements. 1. **Managing UI automation and logic layer workflows** (45:37) — Engineers should write logic assertions inside the common module domain while sustaining isolated test coverage for visual interactions. ## Related Moments - [Solving cross-platform drawbacks with Kotlin Multiplatform](https://www.wearedevelopers.com/videos/4-kotlin-multiplatform-true-power-of-native-code-reuse) (from "Kotlin Multiplatform - True power of native code reuse") - [Key takeaways and future Kotlin Multiplatform improvements](https://www.wearedevelopers.com/videos/4-kotlin-multiplatform-true-power-of-native-code-reuse) (from "Kotlin Multiplatform - True power of native code reuse") - [Centralizing mobile business logic with Kotlin Multiplatform](https://www.wearedevelopers.com/videos/100341-vertical-slice-architecture-micro-frontends-across-mobile-backend-ml) (from "Vertical Slice Architecture: Micro Frontends Across Mobile, Backend & ML") - [Architectural boundaries and the Kotlin Multiplatform survival kit](https://www.wearedevelopers.com/videos/100143-the-dark-corners-of-kotlin-multiplatform) (from "The Dark Corners of Kotlin Multiplatform") - [Developing front-end client applications using Kotlin Multiplatform libraries](https://www.wearedevelopers.com/videos/1184-location-verification-without-gps) (from "Location Verification without GPS?") - [Planning a production application with Kotlin Multiplatform](https://www.wearedevelopers.com/videos/4-kotlin-multiplatform-true-power-of-native-code-reuse) (from "Kotlin Multiplatform - True power of native code reuse") ## Related Articles - [Cross Platform Mobile Development Frameworks to Use in 2025](https://www.wearedevelopers.com/magazine/404-cross-platform-mobile-development-frameworks-to-use-in-2025) - [MLops – Deploying, Maintaining And Evolving Machine Learning Models in Production](https://www.wearedevelopers.com/magazine/115-mlops-deploying-maintaining-and-evolving-machine-learning-models-in-production) - [A Guide to Choosing the Right Tools for App Developers](https://www.wearedevelopers.com/magazine/391-a-guide-to-choosing-the-right-tools-for-app-developers) - [Native Web Apps: Are We There Yet?](https://www.wearedevelopers.com/magazine/83-native-web-apps-are-we-there-yet) ## Related Jobs - [Founding Mobile Engineer (iOS)](https://www.wearedevelopers.com/jobs/ext/1648532-founding-mobile-engineer-ios) at **Almedia** - [Senior Software Engineer, Android (Earn Experience)](https://www.wearedevelopers.com/jobs/ext/1937627-senior-software-engineer-android-earn-experience) at **Bitpanda** - [iOS Engineer, Swift/SwiftUI/Combine (B2C Broker)](https://www.wearedevelopers.com/jobs/ext/1611832-ios-engineer-swift-swiftui-combine-b2c-broker) at **Bitpanda** - [Platform Engineer - Mercury Runtime Platform](https://www.wearedevelopers.com/jobs/ext/293235-platform-engineer-mercury-runtime-platform) at **Raiffeisen Bank International AG** - [Senior Software Engineer, Client Apps Platform](https://www.wearedevelopers.com/jobs/ext/1773893-senior-software-engineer-client-apps-platform) at **GitHub** - [Platform Engineer (f/m/x) - Mercury Runtime Platform](https://www.wearedevelopers.com/jobs/48266-platform-engineer-f-m-x-mercury-runtime-platform) at **Raiffeisen Bank International AG**