I want to use hilt in androidMain of kmm project, ...
# multiplatform
h
I want to use hilt in androidMain of kmm project, how to setup in build gradle.kts
Copy code
androidMainImplementation(libs.hiltAndroid)
    androidMainImplementation(libs.hiltNavigationFragment)
    kapt(libs.hiltAndroidXCompiler)
    kapt(libs.hiltCompiler)
with android, it’s ok but with kapt it cannot build for iosMain
d
It won't be able to, Hilt is built for the JVM only. Two suggestions: read the Kotlin Multiplatform introductory documentation, it may clear up any misunderstanding about how KMP works. Secondly, avoid using codegen/annotation driven DI. Experience tells me it's rarely worth the problems it causes.
🙌 1
j
Check out Koin or another library which supports KMP.
🙌 1
h
thanks guys
t
I think that it is quite shame that Hilt has no real plan to KMM support, since it is Google's officially supported and suggested solution. I hope that it will changes soon. "avoid using codegen/annotation driven DI" yes, there are sadly some issues with that, but reduced complexity by that significantly surpasses any disadvantages. Even Koin has already annotation support and compile time verification, it significantly push the experience forward and save a lot of code. But I still love Hilt much more, especially thanks to Android Studio plugins which is awesome. And also fact, that there is one context one source of true and you can share DI even between libraries. It is possible with Koin, bot not so straightforward.
🙌 1
h
hi @Tomáš Procházka may you provide me the URL link for above information ? thanks a lot
t
Which information exactly?
h
sry 😞 i got mistake when reading your comment
👍 1
891 Views