This might be better in <#C3PQML5NU|multiplatform>...
# compose-desktop
c
This might be better in #multiplatform but I'll ask here first. If I want to write a KMP/KMM application and I want to share composables with desktop + android, and then I want a common networking module for desktop + android + ios, how would you recommend the module structure?
Copy code
/androidApp
/commonCode
  /commonMain
  /desktopMain
  /iosMain
  /androidMain
/iosApp
/desktop
or
Copy code
/androidApp
/commonComposables
  /commonMain
  /desktopMain
  /androidMain
/commonCode
  /commonMain
  /desktopMain
  /iosMain
  /androidMain
/iosApp
/desktop
Basically would you just have a single common module and internally that somehow had both the shared networking code and shared composables (even no compose for ios ui) or just have two modules that are multiplatform modules. one for us and one for network?
👍 1
j
In Compose, we define a
jvmMain
which is a parent of both
desktopMain
and
androidMain
, so anything we want those two modules to share can be placed inside
jvmMain
You can see it here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/ I'm not suggesting this is necessarily better, just an option for your consideration.
👍 1
Also, in case it wasn't obvious how that works, you just make the source set
dependsOn
the other source set: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/build.gradle;l=162
👍 1
x
I recommend nested modules
Copy code
:android
:common
  /commonMain
  /desktopMain
  /androidMain 
  :ui
    /commonMain
    /desktopMain
    /androidMain