Should I make app in KMP or make in Jetpack Compos...
# multiplatform
p
Should I make app in KMP or make in Jetpack Compose and port it to KMP later ? I would use it on iOS only if it progresses far which I am not sure of.
m
Personally, I'd prefer creating a KMP, but leaving any iOS
actual
that needs more than a few lines of code for the future. You can just use dummy implementations for these with TODO statements. This helps drive your decisions, for example, preferring a KMP library to an Android-only one. Also, in most cases, after creating an MVP, you'd be surprised that adding iOS support needs less-than-expected effort. Side Note: Split
:composeApp
right away to
:androidApp
and
:shared
as this is the way to go starting from AGP 9.0.
g
Got more info about that split @Mohamed Darwish?
m
@galex AGP 9.0 is deprecating support for
com.android.application
and
com.android.library
. This means a KMP gradle module cannot be an Android application or use Android build flavors, along with other default behavior changes. Read more at: https://developer.android.com/kotlin/multiplatform/plugin Check the note at the top of the page, and migration steps at the end.
❤️ 1
g
Interesting, I didn't know it was in the works. Do you know of a project example to see this in action in a Compose Multiplatform project?
m
Actually, no. The official KMP wizard hasn't updated the project layout, yet, so community adoption is still limited. I've recommended the new layout here since they are starting a new project, so they don't have to refactor the project layout, soon.
g
Yeah I wondered about that as well... Plus there are still big known issues in the end of this doc, I don't know if it's a good idea yet to migrate. When we'll get closer to 9.0 I guess we'll see more examples and setups then
c
This was actually the original default setup for the template as it always had dedicated iOS and android entry points that was different to the shared compose (or KMP in some cases) entry point.. But somewhere along the line they merged it into this single composeApp that became the shared and android entry point combined. I was never a fan tbh. But either way there should be plenty of GitHub samples around showcasing this, as it was like that for quite some time
g
Interesting, I wonder how that setup look for Compose Multiplatform with the 4 targets of the wizard, Android / iOS / WasmJS / Desktop JVM
r
If you are not more than 70% sure you will be doing the iOS, then: • create clean, "almost pure Kotlin" modules • prefer KMP-compatible dependencies (ktor, DI libraries, etc.) • keep in the back of your mind the potential of migrating afterwards anytime you make a big refactor/add a dependency Then if you do end up choosing KMP, you will have a relatively easy and fast track to just migrate to KMP modules and extract out the platform-specific bits into expect/actual abstractions. Doing this makes sure you still have a benefit even if you don't go the KMP route. If you go the KMP route immediately and end up not needing iOS, then you are committing yourself to some extra unneeded maintenance cost.