I’m trying to build the shared module in my kmm project so i can use it in the iOS project my manager built the project with his MacBook Pro (Intel-based) and its working fine but when i try to build the shared module on my macbook m1 with gradle like this:
./gradlew :shared:build
its end with an error:
> Task :shared:compileKotlinIos FAILED
e: Could not find "org.jetbrains.kotlin.native.platform.CoreFoundationBase" in [<PROJECT_PATH>, /Users/laloush/.konan/klib, /Users/laloush/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.20/klib/common, /Users/laloush/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.20/klib/platform/ios_x64]
more over when i try to rebuild the android project im getting the same error on Task :shared:compileKotlinIos, Task :shared:compileKotlinTvosArm64, Task :shared:compileKotlinTvosX64
This is the shared gradle file
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("kotlinx-serialization")
id("com.android.library")
id("com.squareup.sqldelight")
}
android {
compileSdk = 31
defaultConfig {
minSdk = Versions.min_sdk
targetSdk = Versions.target_sdk
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
val ideaActive = System.getProperty("idea.active") == "true"
kotlin {
// Targets
android()
// Revert to just ios() when gradle plugin can properly resolve it
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
if (onPhone) {
iosArm64("ios")
} else {
iosX64("ios")
}
// TODO: Do same as with iOS?
tvosArm64()
tvosX64()
version = "1.0"
sourceSets {
commonMain {
dependencies {
implementation(Deps.Coroutines.common) {
version { strictly(Versions.coroutines) }
}
implementation(Deps.SqlDelight.coroutines)
implementation(Deps.multiplatformSettings)
implementation(Deps.Koin.koinCore)
implementation(Deps.stately)
implementation(Deps.Ktor.ktorNet)
implementation(Deps.Ktor.ktorNetTls)
implementation(Deps.Ktor.ktorClientCore)
implementation(Deps.Ktor.ktorClientCio)
implementation(Deps.Ktor.ktorWebsockets)
implementation(Deps.Ktor.ktorSerializationJson)
implementation(Deps.Ktor.ktorClientSerialization)
implementation(Deps.KotlinSerialization.kotlinSerialization)
implementation(kotlin(Deps.KermitLogger.stdLib))
implementation(Deps.KermitLogger.kermit)
}
}
commonTest {
dependencies {
implementation(Deps.Ktor.ktorMock)
// implementation(Deps.KotlinSerialization.kotlinReflect)
implementation(kotlin("test"))
implementation("org.jetbrains.kotlin:kotlin-test-common")
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
}
val androidMain by getting {
dependencies {
implementation(kotlin("reflect"))
implementation(Deps.SqlDelight.driverAndroid)
implementation(Deps.SqlDelight.coroutinesJvm)
implementation(Deps.Coroutines.android)
implementation(Deps.AndroidX.lifecycle_viewmodel)
implementation(Deps.timber)
}
}
val androidTest by getting {
dependencies {
implementation(Deps.KotlinTest.jvm)
implementation(Deps.KotlinTest.junit)
}
}
val iosMain by getting {
dependencies {
implementation(Deps.SqlDelight.driverIos)
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
// implementation(Deps.Coroutines.common)
}
}
val tvosArm64Main by getting
val tvosX64Main by getting
configure(listOf(tvosArm64Main, tvosX64Main)) {
dependsOn(iosMain)
}
}
// Configure the framework which is generated internally by cocoapods plugin
targets.withType<KotlinNativeTarget> {
binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework>().forEach {
it.isStatic = false
it.linkerOpts.add("-lsqlite3")
}
}
cocoapods {
summary = "Common library for VBox LiveTV"
homepage = "https://github.com/touchlab/KaMPStarter"
}
}