#multiplatform-random question I'm converting a c...
# random
c
#multiplatform-random question I'm converting a compose android app to ios. I've done a lot of work to the android app to begin with. Moved from hilt to koin. Moved from retrofit to ktor. etc. But... everything is still technically in my android app folder. im curious if i should continue to try to move for my android app module to use multiplatform artifacts (i.e. i use "regular" koin, not kmp koin, and should I move from firebase to the kmp firebase community project). I know I have to make those changes eventually, but do you all think its best to do that first in the android app, and then it should be pretty quick to move my small app over to Compose multiplat? Or should I just slowly move class by class from my android app into cmp? idk. I guess im more worried about if i can just use kmp libraries in an android only app first and if that makes sense to do as a prereq. (like most things) im probably overthinking this. lol
s
It really depends. Minimizing any moving parts when moving to KMP would be a great idea, and that's what I would personally do in this situation. I also have an Android app that I was trying to move to KMP (all platforms), and it was quite an overwhelming amount of work and refactoring to do it all at once, and hampered me from maintaining the Android app as I was working on it, so now I've reverted everything and I'm gradually migrating my Android app to KMP. The planned process (for me at least) is to move away from Android and JVM-specific libraries and SDKs whenever possible, replacing them with KMP replacements (where available). For the rest of platform-specific things, I'll make thin abstractions that are suitable for KMP. After that the next step would be to move everything to an actual KMP project with only the Android target enabled, and move all code to
commonMain
. Since abstractions for platform-specific code would be already ready, it should be as simple as adding
expect
to them in common code, and adding
actual
to the implementation. Then it's time to enable whatever other targets you wanna support. Desktop should be the easiest to begin with, then iOS, then web. Doing it one-by-one is better to not get lost xD. Overall this step may be extremely trivial or a little complicated depending on how tied to the OS your application is. You might have to modify the
expect/actual
abstractions and some common code as you're doing this, since some functionalities may be very different or unavailable on certain platforms (e.g. I've had lots of headaches with JS/Wasm's lack of a file system). Just my two cents, I myself am still in the first step, so this is purely a theoretical roadmap, so take it all with a grain of salt. My app is a Compose app. but the biggest hurdle that it's dealing with files (so
java.io.File
and Android Storage Framework) and folders (picking folders to scan them for certain files). There's Firebase Crashlytics and AdMob, but these are easy to replace. Other than that, everything else is pure Kotlin. I'd imagine for most apps that are simply frontends that request and show data from a server (say, a restaurant app), moving to KMP may not require any platform-specific code at all, especially with the rich ecosystem, especially between Android and iOS.