Is this correct understanding, can someone check &...
# multiplatform
s
Is this correct understanding, can someone check & confirm who has already done this. • We cant' distribute a Kotlin Multiplatform (KMM) module as an
.aar
file and give multiplatform support for downstream consumers. •
.aar
does not include code or targets for other platforms (
iosMain
,
desktopMain
,
jsMain
, etc.) as It is a binary artifact targeting Android only. • If the recipient now wants to build for multiple platforms, they must Use the KMM Module as a source dependency, not aar • That means, Get access to your
shared
module *source code, a*dd it to their own Kotlin Multiplatform project, declare targets (
ios()
,
desktop()
,
wasm()
, etc.), include it in their settings.gradle.kts • Alternatively, If you want to distribute your
shared
module as a true multiplatform library (not just Android
.aar
), you can publish it to maven repo as (
.jar
,
.klib
,
.framework
, etc.) & consumers can then use it in their
kotlin {}
source sets. • With this the consumer will be able to Build and run their project for Desktop, iOS, JS, or other KMP-supported platforms, as long as their project is also set up as a CMP project.
d
Not an expert here, but from my experience, if you publish your multiplatform binary with the
publish
plugin it will generate the correct distributions for each build type (
.aar
for android,
.jar
for jvm, etc) and you can import those in pure android projects without issues. I haven't tested it with iOS and other targets though.
s
Can we reuse the compose views also that are defined in commonMain, if I import say shared-binary.jar or shared-binary.klib inside the other Android project that is actually a KMM project
👍 1