https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

miskalinn

07/07/2021, 11:22 AM
Is compose available on KMM?
j

Jean Carlos

07/07/2021, 11:24 AM
Yes. KMM doesn't care about what you use to design your screen in any platform.
m

miskalinn

07/07/2021, 11:24 AM
Cool
m

matej

07/07/2021, 11:35 AM
@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

miskalinn

07/07/2021, 11:38 AM
then which tool developers are using currently to develop android UI in KMM?
m

matej

07/07/2021, 11:42 AM
@miskalinn on Android you can use Compose
But you can't use it on iOS for example
m

miskalinn

07/07/2021, 11:43 AM
ok
m

matej

07/07/2021, 11:44 AM
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

miskalinn

07/07/2021, 11:45 AM
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

matej

07/07/2021, 11:47 AM
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

miskalinn

07/07/2021, 11:48 AM
That's good to hear. Am I going to stuck down at any general usages?
c

Colton Idle

07/07/2021, 11:56 AM
@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

miskalinn

07/07/2021, 11:59 AM
@Colton Idle was there any hurdles?
m

matej

07/07/2021, 11:59 AM
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

Colton Idle

07/07/2021, 12:00 PM
I haven't gotten too far, but I've been mostly focussing on the compose portions to share on android and desktop.
r

Rodrigo Sicarelli

07/15/2021, 7:40 AM
@miskalinn there is this awesome course from @Mitch where he build an KMM app with Jetpack Compose + SwiftUI. Might be useful for you!
3 Views