From Android to Multiplatform: Migrating real 100% Jetpack Compose App to fully Multiplatform App. Intro
A step-by-step guide to migrating to a Multiplatform Compose Multiplatform app.
App this series will be about: https://play.google.com/store/apps/details?id=tech.mapps.winthedaywinthelife.android
About the app
App is habit tracker like. User is able to define steps in the process and track consistency. User either wins or loses. The goal is to keep win streak going.
Some of the things app is using:
- Jetpack Compose for UI
- Hilt for Dependency Injection
- Jetpack Navigation for navigation
- RevenueCat for monetization
- SQLDelight database
- Custom design system
- Ktor for networking
- Arrow for easier and more enjoyable functional programming
What I’ll cover in this series
I will take bottom-up approach. Migrating:
- Custom components
- Specific tricky UI examples
- Dependency Injection
I had and idea for the app: system that I used to become successful Android Developer. I wanted to automate it and possibly help others. It’s simple and easy. Being Android Developer it was easy to decide how I’ll do it… make an Android app. I was playing around with Kotlin Multiplatform-Mobile for some time but I never used in read project so this was my chance. The original idea was: share logic and have native UIs -> the goal of Kotlin Multiplatform-Mobile, basically.
Going that route was challenging for me. Building Android Compose app was easy for me since I’ve been using Jetpack Compose since it’s pre alpha state and all the way forward. But I had zero experience building iOS apps. I didn’t know anything Swift nor SwiftUI. Zero. Challenge was to learn iOS development with Swift and SwiftUI. It seemed somewhat easy since Swift is similar to Kotlin and SwiftUI is declarative UI framework same as Jetpack Compose. But with this being my side project and I had little time to spare that became more and more unreachable.
At that point I started looking for other solutions. Flutter was out of the question, I don’t like it. I’ve been using Flutter since first developer preview back in 2017 but I never successfully made myself like it and now I’m doing it like this and this… when I need to, but I avoid it as much as possible.
Compose Multiplatform was something I tried couple of time and Desktop support was working fine, iOS not so much. First couple of times I dropped it without even making the app run on iOS but I was following it’s progress closely. It was still in experimental state and documentation was pretty much non-existent so it was a wild card but I decided to try with it. Even if I fail eventually it will hit alpha, beta, stable and I’ll be able to finish the app at that point. When I had iOS “Hello World” app up and running I wrote blog post about it to mitigate bad documentation.
So, I took on the challenge and started the migration process. It was hard, and I faced some weird issues along the way, but eventually, I got onto stable footing and the process began to smooth out. With each issue that I resolved I gained more confidence and the migration process started to become easier.
Despite the challenges that I faced, I was determined to make the Compose Multiplatform migration work. And in the end, all the effort was worth it because I was able to build the multiplatform app I had envisioned. With Compose Multiplatform, I was able to reuse 99% of the code which ultimately led to a more efficient and scalable app.
Stay tuned for the next post in this series, where I will start with a step-by-step guide to migrating your Jetpack Compose app to a fully multiplatform app using Compose Multiplatform.