I have 2 files gradle look like this: in backend m...
# gradle
h
I have 2 files gradle look like this: in backend module i can use Coroutine library, but i can not use kotlinx.Time it make me so confuse build.gradle.kts(backend)
Copy code
plugins {
  id("kotlin-platform-jvm")
  id("kotlin")
  application
}

group = "xxx"
version = "1.0-SNAPSHOT"

repositories {
  jcenter()
}
dependencies {
  implementation(project(":shared", "default"))
  //…
}

application {
  mainClass.set("ServerKt")
}
build.gradle.kts(shared)
Copy code
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("kotlin-android-extensions")
}
group = "xxx"
version = "1.0-SNAPSHOT"

repositories {
    gradlePluginPortal()
    google()
    jcenter()
    mavenCentral()
    maven(url = "<https://kotlin.bintray.com/kotlinx/>")
}
kotlin {
    android()
    ios {
        binaries {
            framework {
                baseName = "shared"
            }
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                //Serialization
                implementation ("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
                //Coroutine
                implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
                //Time
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.1")
            }
        }
        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.0")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.12")
            }
        }
        val iosMain by getting
        val iosTest by getting
    }
}
android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
        versionCode = 1
        versionName = "1.0"
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
}
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)
v
You can use
dependencyInsight
and
dependencies
tasks to get information about what lib makes it to where and why.
👍 1