Is there any proper way to share Android & Des...
# compose-desktop
b
Is there any proper way to share Android & Desktop sources yet? Most of my components will be the same. As far as I can tell, we can't use a common source set because the desktop/android dependencies are different, even though the APIs are mostly identical
j
in the samples you can search something like jvmAndroidMain or something so, I think it is what you want
b
Hmm can't find it
The Kotlin docs say it's not possible: "Kotlin doesn’t currently support sharing a source set for these combinations: • Several JVM targets • JVM + Android targets" https://kotlinlang.org/docs/mpp-share-on-platforms.html#configure-the-hierarchical-structure-manually
j
compose-jb samples I mean, sorry
b
Yeah I've looked through all the gradle files. They all use
commonMain
, but I also have an iOS target. I think Android+Desktop+iOS with code sharing between Android+Desktop is just not supported.
Ah, about iOS I am not sure
the sample is only JVM + android
b
Ah, they are using
kotlin.srcDirs
, not source sets. That's what I'm doing now, it compiles but the IDE does not like it, shows all the imports red
j
that is weird
@Sebastian Sellmair [JB] maybe can help here
b
Well, I feel better about using
srcDir
since that's what their sample does. I guess it's just an IDE issue (using Android Studio 4.2)
j
Ah, problem with 4.2 it is very old compared to the last IDEA version, and IDEA has implemented a lot of bug fixes for multiplatform
b
That's what I figured. Actually I went into my Plugins and noticed a Kotlin plugin update. After update & restart the red is gone / autocomplete is back 🙂
🙂 1
u
jbCompose does not have any android dependencies. So you can share your components in a pure jvmMain and omit androidMain.