I'm trying to create a multiplatform library for kotlin, and I wanna do it with a native cinterop(ted) library.
I'm importing it into gradle, and it loads, if I change commonMain to Native, library loads, otherwise it's just red.
Is what I'm trying to do even possible at this time? Can we import native (cinteropted) libraries into common kotlin?
I'm adding my gradle file at the bottom (Kotlin DSL)
plugins {
id("org.jetbrains.kotlin.multiplatform").version("1.3.41")
id("maven-publish")
}
repositories {
mavenCentral()
}
group = "xyz.mglolenstine"
version = "0.0.1"
kotlin {
jvm()
js {
browser {
}
nodejs {
}
}
// For ARM, should be changed to iosArm32 or iosArm64
// For Linux, should be changed to e.g. linuxX64
// For MacOS, should be changed to e.g. macosX64
// For Windows, should be changed to e.g. mingwX64
linuxX64("linux")
val commonMain by sourceSets.getting {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(fileTree("libs"))
}
}
val commonTest by sourceSets.getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation(fileTree("libs"))
}
}
val jvmMain by sourceSets.getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(fileTree("libs"))
}
}
val jvmTest by sourceSets.getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation(fileTree("libs"))
}
}
val jsMain by sourceSets.getting {
dependencies {
implementation(kotlin("stdlib-js"))
implementation(fileTree("libs"))
}
}
val jsTest by sourceSets.getting {
dependencies {
implementation(kotlin("test-js"))
implementation(fileTree("libs"))
}
}
val linuxMain by sourceSets.getting {
dependencies {
implementation(fileTree("libs"))
}
}
val linuxTest by sourceSets.getting {
dependencies {
implementation(fileTree("libs"))
}
}
}
if there's something I could do to improve the gradle file, please let me know, as I'm still new to Kotlin DSL and improvements are on my TODO.
I suppose that is unavailable, as far as cinterop
tool creates only bindings for an external library, not a representation. And moreover, klib
s are native-only instruments, as you can see in the documentation.