Sean Keane
02/26/2020, 12:22 PMmap
across all three platforms, the packages aren’t being imported. Has anyone else had this issue and managed to rectify it?Sean Keane
02/26/2020, 12:44 PMrusshwolf
02/26/2020, 1:26 PMSean Keane
02/26/2020, 1:31 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
id("org.jetbrains.kotlin.native.cocoapods")
id("kotlin-dce-js")
}
version = Versions.cocoapodVersion
kotlin {
cocoapods {
summary = "Shared Code for Android and iOS"
homepage = "Link to a Kotlin/Native module homepage"
}
android()
js() {
targets {
browser {
@Suppress("EXPERIMENTAL_API_USAGE")
dceTask { keep("kotlin.defineModule") }
}
}
}
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
compilations {
val main by getting {
kotlinOptions.freeCompilerArgs = listOf("-Xobjc-generics")
}
}
}
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-core:${Versions.ktor}")
implementation("io.ktor:ktor-client-json:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization:${Versions.ktor}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.3.70-eap-274")
}
sourceSets["iosMain"].dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-ios:${Versions.ktor}")
implementation("io.ktor:ktor-client-json-native:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization-native:${Versions.ktor}")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.70-eap-274")
}
sourceSets["jsMain"].dependencies {
implementation(kotlin("stdlib-js", version = "1.3.70-eap-274"))
}
}
android {
compileSdkVersion(App.compileSdk)
sourceSets {
getByName("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
java.srcDirs("src/androidMain/kotlin")
res.srcDirs("src/androidMain/res")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutinesCore}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Versions.serializationCommon}")
implementation("io.ktor:ktor-client-android:${Versions.ktor}")
implementation("io.ktor:ktor-client-json-jvm:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization-jvm:${Versions.ktor}")
implementation("androidx.lifecycle:lifecycle-extensions:${Versions.lifecycleVersion}")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycleVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}
tasks {
register("buildNpm") {
doLast {
copy {
from(zipTree("$buildDir/libs/common-js-$version.jar"))
eachFile {
filter { line ->
line.replace("require('kotlin')", "require('./kotlin.js')")
}
}
into("$buildDir/npm")
}
copy {
from("${rootProject.buildDir}/js/packages/common/kotlin-dce/kotlin.js")
into("$buildDir/npm")
}
}
}
named("buildNpm") {
dependsOn("jsJar", "processDceJsKotlinJs")
}
named("build") {
dependsOn("buildNpm")
}
}
Sean Keane
02/26/2020, 1:33 PM// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven(url = "<https://dl.bintray.com/kotlin/kotlin-eap>")
}
dependencies {
classpath("com.android.tools.build:gradle:${Versions.gradle}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
//classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:${Web.frontEndPlugin}")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven(url = "<https://dl.bintray.com/kotlin/kotlin-eap>")
}
}
russhwolf
02/26/2020, 2:19 PMSean Keane
02/26/2020, 2:48 PMSean Keane
02/27/2020, 9:04 AM