Closed StjepanMiske closed 3 months ago
Hi, could you share the build.gradle.kts
file of your shared
Kotlin module?
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
commonMain.dependencies {
//put your multiplatform dependencies here
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
android {
namespace = "com.example.myapplication"
compileSdk = 34
defaultConfig {
minSdk = 34
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
It looks like you are missing the Kotlin implementation:
kotlin {
sourceSets {
all {
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
commonMain {
dependencies {
api("com.rickclephas.kmp:kmp-observableviewmodel-core:1.0.0-BETA-2")
}
}
}
}
I do that and still receive the same error in iOS
You'll only see the Kotlin declarations that are part of the public API of your shared module.
So before the Kmp_observableviewmodel_coreViewModel
type becomes visible in Swift, you would also need to create a ViewModel
in Kotlin.
Once you have a ViewModel both the ViewModel class and the Kmp_observableviewmodel_coreViewModel
type should be visible from Swift.
Oh okay, thx. Can you pls include this in the tutorial just so iOS devs know. I lost entire day trying to figure out why my new project is not recognizing that extension
On Sun, 19 May 2024 at 17:35, Rick Clephas @.***> wrote:
You'll only see the Kotlin declarations that are part of the public API of your shared module. So before the Kmp_observableviewmodel_coreViewModel type becomes visible in Swift, you would also need to create a ViewModel in Kotlin. Once you have a ViewModel both the ViewModel class and the Kmp_observableviewmodel_coreViewModel type should be visible from Swift.
— Reply to this email directly, view it on GitHub https://github.com/rickclephas/KMP-ObservableViewModel/issues/72#issuecomment-2119277662, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2GU47QN2KCFJMZSDZBAJDZDDBD3AVCNFSM6AAAAABH6NWJ6OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGI3TONRWGI . You are receiving this because you authored the thread.Message ID: @.***>
Hi,
I just created an empty Kotlin Multiplatform project and tried to implement your framework on iOS side and this is what I get when I implement extension that you described in the tutorial:
Why is this happening and how can it be fixed? Thx