InsertKoinIO / koin-annotations

Koin Annotations - About Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform insert-koin.io
https://insert-koin.io
Apache License 2.0
163 stars 44 forks source link

Koin Annotations not working for expect/actual classes #188

Closed cj3g10 closed 1 week ago

cj3g10 commented 1 week ago

Describe the bug I'm unsure how to use Koin Annotations with expect/actual classes as it seems to not work no matter how I set it up. The documentation shows that you should annotation to the actual class. On the other hand, the Hello Koin KMP sample app does it different and adds the annotaiton to the expect class. However, no matter whether I add the annotation to the expect class, to the actual class, or to both expect and actual class, Koin will throw a NoDefinitionFoundException. The ksp generated Module file will not contain the annotated class.

Note that if I define the actual class via code, it works fine, so this isn't an issue that is blocking my development.

To Reproduce Steps to reproduce the behavior:

  1. Setup koin.
  2. Create an expect/actual class.
  3. Add @Single or @Factory annotation to the actual class.
  4. Run app and attempt to inject said class.

Expected behavior The class will be injected properly and app will run smoothly.

Actual behavior The app will crash and throw NoDefinitionFoundException.

Koin module and version: koin-annotations:2.0.0-Beta1

arnaudgiuliani commented 1 week ago

fixed in 2.0-Beta2 https://github.com/InsertKoinIO/koin-annotations/pull/189