import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { kotlin("multiplatform") kotlin("plugin.serialization") id("com.android.library") id("kotlin-android-extensions") id("com.squareup.sqldelight") } repositories { gradlePluginPortal() google() jcenter() mavenCentral() maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") } } kotlin { android() val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator" if (sdkName.startsWith("iphoneos")) { iosArm64("ios") { binaries { framework { baseName = "Shared" } } } } else { iosX64("ios") { binaries { framework { baseName = "Shared" } } } } sourceSets { val commonMain by getting { dependencies { implementation(Dependencies.Kotlin.coroutinesCore) // Ktor implementation(Dependencies.Ktor.ktorCore) implementation(Dependencies.Ktor.ktorJson) implementation(Dependencies.Ktor.ktorSerialization) // Serialization implementation(Dependencies.Serialization.json) // SqlDelight implementation(Dependencies.SQLDelight.sqlDelightRuntime) implementation(Dependencies.SQLDelight.sqlDelightCoroutines) } } val androidMain by getting { dependencies { implementation(Dependencies.Kotlin.coroutinesAndroid) // Ktor implementation(Dependencies.Ktor.ktorOkhttp) // SqlDelight implementation(Dependencies.SQLDelight.sqlDelightAndroid) // Misc implementation(Dependencies.Misc.jsoup) } } val iosMain by getting { dependencies { // Ktor implementation(Dependencies.Ktor.ktorIos) // SqlDelight implementation(Dependencies.SQLDelight.sqlDelightNative) } } } } android { compileSdkVersion(Config.Android.compileSdk) sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { minSdkVersion(Config.Android.minSdk) targetSdkVersion(Config.Android.targetSdk) versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } } sqldelight { database("AppDatabase") { packageName = "net.underdesk.circolapp.shared.data" sourceFolders = listOf("sqldelight") } } val packForXcode by tasks.creating(Sync::class) { group = "build" val mode = System.getenv("CONFIGURATION") ?: "DEBUG" val targetName = "ios" val framework = kotlin.targets.getByName(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)