I did it 8 months back, and worse, migrating from XML Views to CMP then KMP. CMP to KMP, I'd say the pain varies greatly depending on what your app does. I hit a lot of bumps because I checked a lot of bad cases: widgets, using Google Drive libraries, etc... Which don't have a KMP library just ready for you to use.
For me the painpoints were:
• How to choose the right CMP library? Or do I code it myself?
◦ When there a lib - do I trust those (I found one on github but didn't open source their code... did I want that? No). Also, not all are mature.
◦ One recommendation: run over to
FileKit Hands-down saved me tens or hundred of hours to handle files in KMP. And the dev is reactive.
◦ Another reco: I ended up spinning out a couple of things I did for Android into separate external KMP libraries. Even if I'm the only user, It still feels, cleaner. So don't discard that possibility.
• iOS & Android aren't the same beasts (as you know :p)
◦ You'll discover race conditions and over fundamental bugs never surfaced in Android - but yes, even from CMP. Or you'll discover you didn't do it exactly properly in Android but need to migrate some stuff to be really multi platforms.
◦ Your architecture choices were made for Android. And some will not be iOS compatible (Widgets, I'm frowning at you)
◦ Don't expect the first
• Usual recos:
◦ Keep iosApp & androidApp thin wrappers
• Gradle as usual will give you headaches
◦ But know that you can propagate variables from KMP package to Android/iOS , with some pain. You can check my main build file for some ideas of KMP parckages I ended up trusting, and have variables available in code & app config (like version name/code)
https://github.com/licryle/Android-HSKFlashcardsWidget/blob/main/crossplatform/build.gradle.kts
• cocoapods vs. frameworks:
◦ Originally cocoapods seemed too daunting and not needed, but I ended up needing other cocoapods and hit incompatibilities, so I ended up migrating it all to cocoapods. Maybe start directly with those.
I'm no longer a professional software engineer (or rather re-ramping up); and I know 0 swift/iOS dev; so take some of these recommendations with a grain of salt though 🙂
But I hope that will help!