140 lines
5.1 KiB
Kotlin
140 lines
5.1 KiB
Kotlin
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
|
||
|
||
plugins {
|
||
alias(libs.plugins.android.kotlin.multiplatform.library)
|
||
alias(libs.plugins.android.lint)
|
||
|
||
// Compose Compiler plugin (Kotlin ≥2.0): krävs för Compose Multiplatform i :shared.
|
||
// Versionen kommer från libs.versions.toml (plugins.kotlin-compose -> kotlin).
|
||
alias(libs.plugins.kotlin.compose)
|
||
|
||
alias(libs.plugins.kotlin.multiplatform)
|
||
alias(libs.plugins.kotlin.serialization)
|
||
|
||
// JetBrains Compose Multiplatform för UI i :shared/commonMain.
|
||
// Viktigt: detta är *inte* AndroidX Compose BOM. Vi använder compose.*-aliasen
|
||
// (org.jetbrains.compose) vilket gör att :shared förblir plattformsneutral.
|
||
id("org.jetbrains.compose") version "1.8.2"
|
||
}
|
||
|
||
kotlin {
|
||
|
||
// Target declarations - add or remove as needed below. These define
|
||
// which platforms this KMP module supports.
|
||
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
|
||
androidLibrary {
|
||
namespace = "app.klottr.shared"
|
||
compileSdk = 35
|
||
minSdk = 26
|
||
|
||
withHostTestBuilder {
|
||
}
|
||
|
||
withDeviceTestBuilder {
|
||
sourceSetTreeName = "test"
|
||
}.configure {
|
||
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||
}
|
||
}
|
||
|
||
// For iOS targets, this is also where you should
|
||
// configure native binary output. For more information, see:
|
||
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
|
||
|
||
// A step-by-step guide on how to include this library in an XCode
|
||
// project can be found here:
|
||
// https://developer.android.com/kotlin/multiplatform/migrate
|
||
val xcfName = "sharedKit"
|
||
val xcf = XCFramework()
|
||
|
||
iosX64 {
|
||
binaries.framework {
|
||
baseName = xcfName
|
||
xcf.add(this)
|
||
}
|
||
}
|
||
|
||
iosArm64 {
|
||
binaries.framework {
|
||
baseName = xcfName
|
||
xcf.add(this)
|
||
}
|
||
}
|
||
|
||
iosSimulatorArm64 {
|
||
binaries.framework {
|
||
baseName = xcfName
|
||
xcf.add(this)
|
||
}
|
||
}
|
||
|
||
// Source set declarations.
|
||
// Declaring a target automatically creates a source set with the same name. By default, the
|
||
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
|
||
// common to share sources between related targets.
|
||
// See: https://kotlinlang.org/docs/multiplatform-hierarchy.html
|
||
sourceSets {
|
||
commonMain {
|
||
dependencies {
|
||
implementation(libs.kotlin.stdlib)
|
||
implementation(libs.ktor.client.core)
|
||
// Add KMP dependencies here
|
||
|
||
implementation(libs.ktor.client.content.negotiation)
|
||
implementation(libs.ktor.serialization.kotlinx.json)
|
||
// JSON-runtime explicit (bra för versionssäkring)
|
||
implementation(libs.kotlinx.serialization.json)
|
||
implementation(libs.ktor.client.logging)
|
||
|
||
// CMP-runtime & foundation. Paketnamnen i koden är androidx.compose.*,
|
||
// men artefakterna kommer från JetBrains Compose via compose.*-aliasen.
|
||
// Lämna AndroidX Compose BOM/runtimes utanför :shared.
|
||
implementation(compose.runtime)
|
||
implementation(compose.foundation)
|
||
|
||
// för Compose i :shared (Android-del)
|
||
// OBS: Dessa AndroidX Compose-rader ska förbli utkommenterade i :shared.
|
||
// :shared använder JetBrains Compose (org.jetbrains.compose) för CMP.
|
||
//implementation(project.dependencies.platform("androidx.compose:compose-bom:${libs.versions.composeBom.get()}"))
|
||
//implementation(libs.androidx.ui)
|
||
//implementation(libs.androidx.material3)
|
||
}
|
||
}
|
||
|
||
commonTest {
|
||
dependencies {
|
||
implementation(libs.kotlin.test)
|
||
}
|
||
}
|
||
|
||
androidMain {
|
||
dependencies {
|
||
// Add Android-specific dependencies here. Note that this source set depends on
|
||
// commonMain by default and will correctly pull the Android artifacts of any KMP
|
||
// dependencies declared in commonMain.
|
||
implementation(libs.ktor.client.okhttp)
|
||
|
||
}
|
||
}
|
||
|
||
getByName("androidDeviceTest") {
|
||
dependencies {
|
||
implementation(libs.androidx.runner)
|
||
implementation(libs.androidx.core)
|
||
implementation(libs.androidx.junit)
|
||
}
|
||
}
|
||
|
||
iosMain {
|
||
dependencies {
|
||
// Add iOS-specific dependencies here. This a source set created by Kotlin Gradle
|
||
// Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as
|
||
// part of KMP’s default source set hierarchy. Note that this source set depends
|
||
// on common by default and will correctly pull the iOS artifacts of any
|
||
// KMP dependencies declared in commonMain.
|
||
implementation(libs.ktor.client.darwin)
|
||
}
|
||
}
|
||
}
|
||
|
||
} |