https://kotlinlang.org logo
Title
b

Brian G

05/25/2021, 1:09 PM
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

Javier

05/25/2021, 1:11 PM
in the samples you can search something like jvmAndroidMain or something so, I think it is what you want
b

Brian G

05/25/2021, 1:14 PM
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

Javier

05/25/2021, 1:18 PM
compose-jb samples I mean, sorry
b

Brian G

05/25/2021, 1:19 PM
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

Brian G

05/25/2021, 1:20 PM
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

Javier

05/25/2021, 1:21 PM
that is weird
@Sebastian Sellmair [JB] maybe can help here
b

Brian G

05/25/2021, 1:23 PM
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

Javier

05/25/2021, 1:28 PM
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

Brian G

05/25/2021, 1:41 PM
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

uli

05/25/2021, 8:32 PM
jbCompose does not have any android dependencies. So you can share your components in a pure jvmMain and omit androidMain.