Hey, After lots of confusion and chat with AIs. I ...
# multiplatform
r
Hey, After lots of confusion and chat with AIs. I decided to learn KMP and later will move to CMP. And currently I have been building lots of apps in KMP for android only. And in learning process to SwiftUI for iOS screen building. BUT in the process I realised both KMP and CMP are built on same tech.. so I was thinking on KMP project can we add support for desktop and web too.? Creating UI using compose for android, web and desktop and using SwiftUI for iOS. well it is answered by ChatGPT and Gemini that it is possible. but I am not able to build the project once I add support of them. Could someone please answer. If they have tried it and it worked.
a
If you're looking for desktop and web as well, a CMP project makes the most sense (assuming your goal is to reuse the UI as much as possible). We typically use KMP for functional libraries that are shared across architecture. Our web interfaces, for example, are not in compose and share no UI with our mobile apps, so having a KMP library where our web applications can share the model and logical elements with our compose apps makes sense. Also worth mentioning, the only thing that makes a CMP project CMP is that compose is used in the applications and configured as such. For iOS for example, thats just a boilerplate controller and you could otherwise just write swift code for your views. We do both in fact.
👀 1
j
I think using CMP and writing the UI once makes the most sense. No need to native (Swift UI) when Compose can fit the job and offer great performance. It recently went stable so there should be any major concerns going to production.
👍 1
r
@Anonymike so would you suggest for going directly for CMP if my focus is building application for users? or should I go step by step from KMP to CMP?
a
Personally I would recommend going CMP, especially if this is early in your Kotlin learning. That way you'll have all the resources and you can learn more about jumping out of Kotlin into Swift for example if its necessary.
But a multi-architecture app is a lot to learn if you're not already familiar with gradle, mobile apps, or kotlin already.
r
stupid question? what is CMP?
a
@ron Not a stupid question. I'm not a fan of acronyms either lol. Compose Multi-Platform
r
Yes, KMP = "Kotlin Multi-Platform", which refers to the system that lets you have shared Kotlin code that can be used by applications that are compiled for different platforms. Here is the list of platforms that KMP can compile for: https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-dsl-reference.html#targets CMP = "Compose Multi-Platform" is a UI system based on Android's Jetpack Compose, but built on KMP to support more than just Android. CMP lets you use shared Kotlin code to define UI that works on multiple platforms. CMP is supported for a subset of KMP's compile targets, listed here: • Android • iOS • JVM (aka "desktop") • Web via Wasm, but it's still alpha
p
@RANJAN - if your use case is to use WASM with CMP, please note it's only going to Beta later this year
☝️ 1