https://kotlinlang.org logo
#koin
Title
# koin
v

Vedran

03/07/2024, 12:30 PM
Can anyone help with adding Koin annotaions for desktop compose project? I have in my build.gradle.kts:
Copy code
plugins {
    kotlin("jvm")
    id("org.jetbrains.compose")
    kotlin("plugin.serialization") version "1.9.20"
    id ("com.google.devtools.ksp") version "1.9.22-1.0.17"
}
and also inside dependencies:
Copy code
// KOIN
    implementation(platform("io.insert-koin:koin-bom:3.5.4-RC1"))
    implementation("io.insert-koin:koin-core")
    implementation("io.insert-koin:koin-compose")

    implementation(platform("io.insert-koin:koin-annotations-bom:1.3.1"))
    implementation("io.insert-koin:koin-annotations")
    implementation("io.insert-koin:koin-ksp-compiler")
and :
Copy code
ksp {
    arg("KOIN_CONFIG_CHECK","true")
}
Im able to use annotations and create modules but I'm not able to startKoin:
Copy code
import org.koin.ksp.generated.module
this import is not existing (unresolved reference) and also when I try to access my module inside startCoin: MyModyle().module .module does not exist
j

Jacob Ras

03/07/2024, 11:18 PM
Some questions that pop up: Does your model have the
@ComponentScan
annotation? Are the things annotated with
@Single
/
@Factory
in the same module & package? In what source set are they? But the most important one might be this: How does your ksp configuration look? In the code above I don't see anything like
add("ksp...
. See https://medium.com/@jacobras/using-ksp-with-kotlin-multiplatform-a-quick-overview-6b858df77b5f for some info about the syntax.
v

Vedran

03/08/2024, 12:39 AM
Thank you! I've made it work by adding first this:
Copy code
add("ksp", "io.insert-koin:koin-ksp-compiler:1.3.1")
then
@ComponentScan
, I have my module in root folder. In most of examples I saw just adding
@ComponentScan
above module is enough... My generated module always has error: a dot before:
Copy code
public val .PulsefireModule.module : org.koin.core.module.Module get() = _PulsefireModule
removing this dot works... Or if I just use default module
a

arnaud.giuliani

03/08/2024, 8:06 AM
is it a package issue here? where does you module live?
☝️ 1
14 Views