Kroppeb
07/10/2020, 8:48 AMCannot access built-in declaration '...'. Ensure that you have a dependency on the Kotlin standard library
I'm confused as to why it can't find the stdlib?russhwolf
07/10/2020, 12:21 PMimplementation(kotlin("stdlib"))
in your jvmMain
dependencies.Kroppeb
07/10/2020, 12:40 PMrusshwolf
07/10/2020, 12:41 PMkotlin("stdlib")
vashisthg
07/11/2020, 12:43 PMjvmTest
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
}
kotlin {
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "recommendations"
}
}
}
jvm("android")
jvm()
sourceSets["commonMain"].dependencies {
implementation(kotlin("stdlib-common"))
}
sourceSets["androidMain"].dependencies {
implementation(kotlin("stdlib"))
}
sourceSets["jvmMain"].dependencies {
implementation(kotlin("stdlib-common"))
}
sourceSets["commonTest"].dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
sourceSets["androidTest"].dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
// JVM-specific tests and their dependencies:
jvm().compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
}
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText("#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n")
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
sourceSets["jvmMain"].dependencies {
implementation(kotlin("stdlib-jdk8"))
}