-
|
I used It works well on android and JVM, but failed on iOS platform. I think this problem is something releated to Kotlin Native, but it's hard to solve. Can I get a help for this problem? I made a sample reproduceable project here: https://github.com/kingori/IosMetroVmClassFindFail I have two modules, :composeApp and :submodule and defined ViewModel on :submodule. @Inject
@ViewModelKey(SubViewModel::class)
@ContributesIntoMap(AppScope::class)
@ObjCName("SubViewModel")
class SubViewModel( val subItem: SubItem) : ViewModel() {
val _state = MutableStateFlow(0)
val state : StateFlow<Int> = _state.asStateFlow()
fun increase() {
_state.value += 1
}
}When I tried to use it in :composeApp or :submodule, app crashed. // use viewmodel in :submodule - failed
@Composable
fun SubVmScreenInSubModule(onNavigateBack: () -> Unit, viewModel: SubViewModel = metroViewModel()) {
// use viewmodel in :composeApp - failed
@Composable
fun SubVmScreen(onNavigateBack: () -> Unit, viewModel: SubViewModel = metroViewModel()) {I think this problem is releated to project's settings. Is there any solution for this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Per the docs, contributing bindings across modules in non-jvm compilations doesn't work yet. Follow #460 |
Beta Was this translation helpful? Give feedback.
Per the docs, contributing bindings across modules in non-jvm compilations doesn't work yet. Follow #460