Is compose available on KMM?
# multiplatform
m
Is compose available on KMM?
j
Yes. KMM doesn't care about what you use to design your screen in any platform.
m
Cool
m
@Jean Carlos @miskalinn but to be precise, it doesn't mean that you can just build your UI in compose and it will work on all (or even most) of the different platforms that KMM can target. Not for a long while at least.
m
then which tool developers are using currently to develop android UI in KMM?
m
@miskalinn on Android you can use Compose
But you can't use it on iOS for example
m
ok
m
Then again you could use it on Windows. My point was, you can't build one UI with compose and use it everywhere, in KMM UI is generally handled separately for each platform. What you share can be some UI logic (e.g. viewmodels, presenters, etc.) but the actual layouts and view hierarchies are platform specific and usually done in the native platform way.
👍 1
KMM is totally non-opinionated about UI, so you can use whatever is the best practice or your personal favorite for each platform.
m
ok, I was planning to use swiftUI for ios. so that's fine
👍 1
I have a smalll ecommerce project, is KMM ready build these
I have seen several blogs saying that, but not sure
m
From my point of view, yes. We are using it in an enterprise app in production for close to a year now. It still has some rough edges and headscratchers from time to time, but overall I think it's pretty stable and mature at this point.
And it's getting better at a good pace.
m
That's good to hear. Am I going to stuck down at any general usages?
c
@miskalinn I'm doing a new project now and using swiftUI for ios, and using compose for android and desktop. Join #compose-desktop for more info!
m
@Colton Idle was there any hurdles?
m
The roughest part is probably still the memory model on native (AKA anything other than JVM and JS). It means you have to be careful how you share objects between threads on iOS for example, or if you can, completely avoid it. Otherwise it could cause a crash. You can read more about it in an excellent series of blog posts by Kevin Galligan (here's the latest on the topic: https://medium.com/@kpgalligan/ktor-and-kotlin-native-fb5c06cb920a). He is also present in this Slack from time to time. Long story short, if you're targeting iOS, you're best off using coroutines to suspend without blocking the UI, and just sticking to the main thread. If you have really long running operations or some heavy processing in your app, you could explore how to accomplish safe multithreading with Kotlin Native. That's too big of a topic to go into here, for most simple apps that won't be necessary and once JetBrains change the memory model, it will be a thing of the past.
c
I haven't gotten too far, but I've been mostly focussing on the compose portions to share on android and desktop.
r
@miskalinn there is this awesome course from @Mitch where he build an KMM app with Jetpack Compose + SwiftUI. Might be useful for you!