composeApp

composeApp is a Kotlin module that contains the logic shared among the Android, desktop, iOS, and web applications – the code you use for all the platforms. It uses Gradle as the build system that helps you automate your build process.

The composeApp module consists of the following source sets:

  • androidMain
  • commonMain
  • desktopMain
  • iosMain
  • wasmJsMain.

A source set is a Gradle concept for a number of files logically grouped together, where each group has its own dependencies. In Kotlin Multiplatform, different source sets can target different platforms.

The commonMain source set uses the common Kotlin code, and platform source sets use Kotlin code specific to each target. Kotlin/JVM is used for androidMain and desktopMain. Kotlin/Native is used for iosMain. On the other hand, Kotlin/Wasm is used for wasmJsMain.

When the shared module is built into an Android library, common Kotlin code gets treated as Kotlin/JVM. When it is built into an iOS framework, common Kotlin code gets treated as Kotlin/Native. When the shared module is built into a web app, common Kotlin code gets treated as Kotlin/Wasm.

References


Backlinks