Hi! I'm migrating a KMP project to Koin 4 and Koin...
# koin
g
Hi! I'm migrating a KMP project to Koin 4 and Koin-Annotation 2 but the definition of my module moved from
commonMain
to
androidMain
! In fact, there is still a
defaultModule
in the
commonMain
with 2
@Factory
. All of my
@Single
is now in my custom Module in
build/generated/ksp/android/androidDebug/kotlin/org.koin.ksp.generated
. I tried koin-annotations 2.0.1-RC1 seeing this PR :
Fix - Fix all kmp generation from commonMain to native side by @arnaudgiuliani in #258
but still the same. This project doesn't have any module, singleton or factory on the platform side. Do you have any idea of what is happening?
a
definitions can"t be scanned from common side, apart using an expect module and using actual module on native side
?
g
@arnaud.giuliani Thanks for your reply but I'm not sure what you mean by that. > definitions can"t be scanned from common side In the link your provided, in
common/di/Modules.kt
, there is for example, the
ViewModelModule
, with
ComponentScan
. That's exactly like mine. The only difference, is that this one is included in the
AppModule
and this is this last one which is used in the
startKoin
. If I do the same, the AppModule is also generated in
build/generated/ksp/android/androidDebug/kotlin/org.koin.ksp.generated
. > did you took a look at gs example Not recently, as this project is running in production with Koin 3.5
I just tried to rollback to 3.5 and everything work fine. With 4.0, if in the dependencies, I only put
Copy code
add("kspCommonMainMetadata", libs.koin.ksp.compiler)
my custom modules are not generated. I only get a default module containing only my factory, no singleton. As soon as I add
Copy code
add("kspAndroid", libs.koin.ksp.compiler)
My custom modules appear but under the wrong generated folder. But my
@Factory
are still under a default module. That's weird because both are under the same package, which is the one defined in the
@ComponentScan
@arnaud.giuliani This morning, I think I scoped the issue to the this release: koin-annotations 2.0.0-RC1 . The 2.0.0-Beta3 was still working. With this version, my shared module moved to the target side so I can't use them in my common code. I will synthesize this in a github bug
a
Yes, thanks. I will catchup soon on KA 2.0.1
can you help reproduce ?
g
I'm trying with the project in KMP-App-Template right now, without success
👍 1
a
is it a case of Scoped definition?
g
In case you missed, I created this bug: https://github.com/InsertKoinIO/koin-annotations/issues/270
Hum I didn't used this feature
a
ok
g
Ok I find something interesting! I'll give explanation in the bug. TLDR: Looks like a conflict between Koin and another lib using ksp
a
ok interesting. Which one is it?
g
Trikot ViewModels, from Mirego