This repository is a template for implementing multimodule in Kotlin Multiplatform(KMP).
tool | version |
---|---|
Kotlin | 2.0.0 |
org.jetbrains.compose | 1.6.10 |
com.android.application | 8.3.0 |
- Clone repository
git clone git@github.com:Tatsumi0000/KMP-Multimodule-Template.git
- Copy directory hoge to directory KMP project.
- Rename
package_name
andhoge
folder name. - Add the module include to settings.gradle.kts in the KMP project.
// settings.gradle.kts(your KMP project)
include(":hoge")
- Fix build.gradle.kts. (FIXME is written where corrections are needed)
- Load the module in the module you want to use in the build.gradle.kts in your KMP project.
// build.gradle.kts(:composeApp)
kotlin {
sourceSets {
commonMain.dependencies {
implementation(project(":hoge"))
}
}
An example implementation can be found in this repository.
It appears that the directory name must contain commonMain
.
Class is recognized by the androidMain
and iosMain
packages even though it does not contain commonMain
, but not by commonMain(:composeApp)
.