google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.44k stars 2.02k forks source link

Add KMP support for @HiltViewModel annotation #4291

Closed IsakTheHacker closed 5 months ago

IsakTheHacker commented 6 months ago

The team responsible for making AndroidX Lifecycle is currently making great progress on converting the library to Kotlin Multiplatform and I think we are expecting a release soon as the new version (2.8.0) is currently in beta. This update will allow us to put ViewModels in common source sets so I see a lot of value in making Hilt and the @HiltViewModel annotation compatible with KMP. I don't have the skills needed to know if this would require a major rework or not though so please tell me if this is out of scope for now.

Thank you beforehand and thanks for making one of the best dependency injection frameworks for Android!

Chang-Eric commented 6 months ago

I just posted a response about general KMP support in https://github.com/google/dagger/issues/3916#issuecomment-2096570308. In this case though, are you asking about something specific to the @HiltViewModel annotation (like just asking for that specific annotation to move to common without us providing other platform support) or just about general KMP support?

RowlandOti commented 5 months ago

Facing this bug here: https://github.com/google/dagger/issues/4320