koin-annotations icon indicating copy to clipboard operation
koin-annotations copied to clipboard

ComponentScan generates an empty module when using expect/actual classes

Open mattegoghero opened this issue 1 year ago • 1 comments

Describe the bug When creating a @Module with @ComponentScan in a KMP project it seems that it's completely ignoring the expect/actual classes (inside the package specified to @ComponentScan) that is supposed to include in the annotated module.

To Reproduce Download the sample project that I attached, it should contain all the configuration provided in the guide. Launch: ./gradlew clean kspCommonMainMetadata Go to: org/koin/ksp/generated/MyModuleGencom$test$koin$annotations.kt Look at the generated module, it should be empty.

Expected behavior The generated module should contain the singleton definition for MyComponent

Koin project used and used version (please complete the following information): ksp: 2.0.20-1.0.25 koin: 4.0.0 koin-annotations: 2.0.0-beta02

The test project: KoinAnnotationTest 2.zip

mattegoghero avatar Nov 23 '24 19:11 mattegoghero

Also if trying to inject an expected class as a dependency it will fail

ciprig avatar Feb 20 '25 22:02 ciprig

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 21 '25 01:07 stale[bot]

Module, ComponentScan and Expect classes are in common. Just implement actual class on other native targets.

did you followed those docs? https://insert-koin.io/docs/reference/koin-annotations/kmp#sharing-patterns

Look at 2.1.1-Beta1

arnaudgiuliani avatar Jul 22 '25 12:07 arnaudgiuliani

I followed https://insert-koin.io/docs/reference/koin-annotations/kmp/#sharing-expectactual-module---rely-on-native-module-scanning @Single annotation does not work (ksp generates empty module), but @Singleton does 🙃

igozhenko avatar Aug 07 '25 14:08 igozhenko

lol ok 😅

arnaudgiuliani avatar Aug 08 '25 15:08 arnaudgiuliani