How do I deal with Dagger when going multuplatform?
Obviously it cannot be in common, but I already have a project written and @Inject constructors everywhere
Should I remove @Inject ctors and move to a @Module which would live in androidMain?
Or is there a way to bend it so I don"t have to rewrite source? i.e. keep the @Inject annot. in common and somehow just expect actual it?
s
streetsofboston
05/10/2024, 1:09 PM
Do you have to use Dagger or could you use kotlin-inject as well? IIRC, kotlin-inject supports the same DI annotations.
u
ursus
05/10/2024, 1:11 PM
I want to try kmm on a "side feature", dont want to migrate whole huge codebase first
p
Pablichjenkov
05/10/2024, 8:11 PM
Unfortunately the code dagger generates is java. It will only be valid code in desktop and Android targets.
u
ursus
05/10/2024, 10:25 PM
I know, I want to actually run it in on android, but dagger uses ctor annotations
I dont want to change the library. I only want to not have it in common. But that means to remove the annotation. Or is there a way to expect actual it?
p
Pablichjenkov
05/11/2024, 12:18 AM
I see what you mean. I believe you can do that yes, expect/actual the annotation.