Blog Infos
Author
Published
Topics
, , , ,
Published

Visualizing the Future of Code Sharing Across Platforms

Kotlin Multiplatform is one of my favorite tools right now.

This year, I’ve been exploring it more deeply and have created a few projects to take full advantage of what it has to offer.

Although setting it up can sometimes be challenging, once you have everything configured, the benefits are truly rewarding.

One of the best features of Kotlin Multiplatform is its flexibility and how seamlessly it integrates into existing projects.

Unlike other cross-platform tools that often require a complete rewrite or drastic changes, Kotlin Multiplatform allows you to incrementally adopt shared code across platforms while still retaining full control over platform-specific implementations.

Since I’ve been working with it and trying out Excalidraw, I was having fun and putting together some diagrams to illustrate how Kotlin Multiplatform can be integrated into various architectures.

These diagrams serve as my reference, and I hope they’ll be helpful to you as well.

Why Kotlin Multiplatform?

Kotlin Multiplatform (KMP) allows you to share core logic between multiple platforms like Android, iOS, and even the web or desktop, while still keeping full access to platform-specific APIs when needed.

What makes it stand out from other cross-platform solutions is its adaptability.

You don’t have to replace your existing architecture — instead, you can integrate KMP into your current project in a modular fashion, choosing which layers you want to share and which ones to keep platform-specific.

Integrating Kotlin Multiplatform and Other Development Strategies
1. Normal Approach

In a traditional setup, iOS and Android applications are developed separately, with no shared code between the platforms.

This approach can lead to duplicated effort as each platform requires its own UI, business logic, and data handling implementation.

2–1. Kotlin Multiplatform and Native UI

The first step toward a multiplatform approach is to keep the native UI separate while sharing the core logic.

In this case, Kotlin Multiplatform is applied to the business and data logic, but the UI is still developed natively for iOS and Android.

This allows for shared logic without disrupting platform-specific UI features.

2–2. Kotlin Multiplatform and Compose Multiplatform

If you want to take it a step further, you can use Compose Multiplatform to unify your UI across platforms.

This approach allows you to share UI components between Android and iOS, providing a consistent design while reusing the same code.

Compose Multiplatform is particularly exciting because it simplifies the process of developing cross-platform UIs, making it easier to maintain consistency across your app’s look and feel.

You still have the option to apply platform-specific tweaks where needed.

3. UI and Data Layer Separation: A Structured Approach

One of the key benefits of Kotlin Multiplatform is its ability to fit into an existing architecture.

This diagram shows how a typical project can be layered into UI and Data Layers. Even without Kotlin Multiplatform, this structure helps in decoupling the different parts of the project, making it easier to update or refactor specific areas.

4. Kotlin Multiplatform in the Data Layer

Here, Kotlin Multiplatform is introduced into the Data Layer, enabling shared code for data handling across platforms.

With this approach, the Data Layer can be implemented once in Kotlin and reused across both iOS and Android, reducing duplication and keeping data-related logic consistent.

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

, ,

Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love

Kotlin Multiplatform Mobile (KMM) is awesome for us Android Developers. Writing multiplatform code with it doesn’t diverge much from our usual routine, and now with Compose Multiplaform, we can write an entire iOS app without…
Watch Video

Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love

André Oriani
Principal Software Engineer
Walmart

Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love

André Oriani
Principal Software E ...
Walmart

Writing Kotlin Multiplatform libraries that your iOS teammates are gonna love

André Oriani
Principal Software Engine ...
Walmart

Jobs

5. Kotlin Multiplatform in the Presentation Layer

Moving further up the architecture stack, this diagram shows how Kotlin Multiplatform can be applied to the Presentation Layer, which includes both UI components and the logic that manages data presentation (e.g., ViewModels).

By sharing the Presentation Layer, you ensure that the way data is presented is uniform across platforms.

6. Compose Multiplatform

For cases where you want to share only the UI components, Kotlin Multiplatform can be applied using Compose Multiplatform.

This allows you to create and reuse UI code across platforms while keeping the business logic and data handling platform specific.

7. Kotlin Multiplatform in both Presentation and Data Layer

In this approach, Kotlin Multiplatform is applied to both the Presentation Layer (UI and ViewModel logic) and the Data Layer.

This allows for significant code reuse, covering both the business logic and the data-handling mechanisms, while the UI is also shared through Compose Multiplatform.

Final Thoughts

Kotlin Multiplatform is not just a tool for new projects; it’s a highly adaptable solution that can integrate into existing applications. By applying it layer by layer, you can take advantage of code sharing while maintaining the flexibility to customize platform-specific features where necessary.

For me, working with KMP has been a game-changer, and I’m excited to see how it evolves in the coming years. If you’re considering adopting Kotlin Multiplatform, start small — perhaps with the Data Layer or Domain Layer — and build from there. The flexibility, reusability, and incremental adoption model make it a powerful addition to any native mobile development project.

I’ve uploaded these diagrams, along with a few additional visual guides not included in this article, to my GitHub for reference and for fun.

Feel free to check them out here, and if you find them useful, I’d appreciate it if you could give the repository a star!

This article is previously published on proandroiddev.com

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
It’s one of the common UX across apps to provide swipe to dismiss so…
READ MORE
blog
Hi, today I come to you with a quick tip on how to update…
READ MORE
blog
Automation is a key point of Software Testing once it make possible to reproduce…
READ MORE
blog
Drag and Drop reordering in Recyclerview can be achieved with ItemTouchHelper (checkout implementation reference).…
READ MORE
Menu