In KMP, can I create a pure Kotlin module? That is...
# multiplatform
p
In KMP, can I create a pure Kotlin module? That is, a module that does not specify targets to be used in other modules? Just using the core language constructs and stdlib. I'm using this build.gradle.kts (but other modules can't see this module's classes):
Copy code
plugins {
    alias(libs.plugins.kotlinMultiplatform)
}

kotlin {
    sourceSets {
        commonMain.dependencies {
           // dependencies
        }
    }
}
🚫 1
p
Thanks! I was just trying to get the minimal build.gradle.kts for a simple KMP module but I can only get this so far:
Copy code
plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
}

kotlin {
    androidTarget()

    iosX64()
    iosArm64()
    iosSimulatorArm64()
    
    jvm()
}

android {
    namespace = "com.romano.gaia.domain"
    compileSdk = libs.versions.android.compileSdk.get().toInt()
}
Is this the minimal configuration file for a module that targets android,ios and desktop?
e
jvm()
will work for Android consumers too, if you don't need to interact with the Android SDK or Android libraries in your own code. including
androidTarget()
is sufficient if you do. there's a whole range of
watchos
and
tvos
targets which ios consumers might expect.
👍 1
l
You may also want to specify the macOS, Linux, and Windows native targets.