I'm building an app for Android and iOS and I want to reuse as much code as possible. I have some generic C code (an algorithm) that doesn't include any system library. Is it possible to expose it to my common Kotlin source set using cinterop or any other tool?
My build.gradle.kts:
plugins {
id("com.android.library")
kotlin("multiplatform")
kotlin("native.cocoapods")
}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
}
sourceSets.all {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
java.srcDirs("src/androidMain/java")
res.srcDirs("src/androidMain/res")
}
}
version = "1.0"
kotlin {
android()
ios()
cocoapods {
// Configure fields required by CocoaPods.
summary = "..."
homepage = "..."
// You can change the name of the produced framework.
// By default, it is the name of the Gradle project.
frameworkName = "SharedModule"
}
// Workaround for ios platform imports to work on Android Studio
// iosX64("ios")
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
sourceSets.all {
languageSettings.progressiveMode = true
}
}