Krotick
12/26/2020, 6:13 PMMarc Knaup
12/26/2020, 6:54 PMjdamcd
12/26/2020, 6:56 PMKrotick
12/26/2020, 11:16 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
val ktorVersion = "1.5.0"
plugins {
kotlin("multiplatform")
id("com.android.library")
}
kotlin {
android()
ios {
binaries {
framework {
baseName = "shared"
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation("com.google.android.material:material:1.2.1")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting
val iosTest by getting
}
}
android {
compileSdkVersion(30)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(30)
}
buildToolsVersion = "30.0.3"
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
My expectation was that adding:
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
will allow me to import io.ktor.etc in src/commonMain/kotlin/… files. But no such luckcy
12/27/2020, 6:43 AMKrotick
12/28/2020, 11:30 PM