I believe I have come up with a solution to this q...
# koin
j
I believe I have come up with a solution to this question here. Though, I’ve not been able to test it, yet. I’m following this guide to setup custom modules setup so that my platform (Android/iOS) specific sourceSet code gets picked up. I believe I have everything set correctly as I can KSP generated code in the
commonMain/
sourceSet. The concern I have is that “native” component scanning doesn’t seem to work. Reviewing the
androidMain/
generated code I don’t see Koin declarations for classes I’ve marked with`@Single` . The generated module for
actual class NativeModule
is empty. I don’t see one at all for
iosMain/
. Has anyone else experienced this? https://kotlinlang.slack.com/archives/C67HDJZ2N/p1757211546010449
a
You can take a look at this project to help you: https://github.com/InsertKoinIO/koin-annotations/tree/main/example-cmp
any setup issue wit the KSP metadata part?
j
Last night I was able to get the
androidMain/
code to generate a module graph using the Assemble Build menu option. The issue I was having was related too using the same
@ComponentScan(MY_PACKAGE_PATH)
in
commonMain/
and
androidMain/
sourceSets. It appears that using the same path in the main source set will “prevent” the target source set from running. The
iOSMain/
generated module graph for me only when launching on a simulator/physical iOS device. Is this intentional?
a
in last versions (2.1.1 & 2.2.0) you can use @ComponentScan in one side only: either you want to scan for commonMain components (with their actual definitions in android/iOS) either you a expect/actual module, to run @ComponentScan on each native side
j
That matches the behavior I saw last night… Can you confirm my suspension about the
iosMain/
generated module graph?