rickclephas / KMP-ObservableViewModel

Library to use AndroidX/Kotlin ViewModels with SwiftUI
MIT License
591 stars 28 forks source link

KMP-NativeCoroutines and moko-resources conflict #32

Closed ldobransky closed 1 year ago

ldobransky commented 1 year ago

Hello I have in viewmodel variables like private val _loginState = MutableStateFlow<LoginStatus>(viewModelScope, LoginStatus.NonAuthenticated) @NativeCoroutinesState val loginState = _loginState.asStateFlow()

but in iOS when I have created viewmodel I can't have access to this variable, functions are visible, calling that functions is working well. Can somebody help me where I have issue?

image
rickclephas commented 1 year ago

Hi! A couple questions to better understand your project:

ldobransky commented 1 year ago
  1. yes in shared build.kts.gradle id("com.google.devtools.ksp") version "1.8.21-1.0.11"
  2. yes it's in shared module
  3. I have class class LoginViewModel: shared.LoginViewModel { } and then in view @StateViewModel var viewModel = LoginViewModel()

rickclephas commented 1 year ago

Alright that looks good. Is this an open-source project, or could you share a reproduction project?

ldobransky commented 1 year ago

I found new info, there is conflict with moko resources library and ksp... so going try to solve this `Some problems were found with the configuration of task ':shared:kspKotlinIosX64' (type 'KspTaskNative').

rickclephas commented 1 year ago

Alright, I am unsure if that is related to the issue, but please do let me know if you have more details on how to reproduce the issue.

ldobransky commented 1 year ago

I think we should rename the ticket to something like add support with moko resources library, because when I want to use this library and moko resources there is a conflict what I sent above. When I removed moko from project, kmm-viewmodels start working. So I can edit the title of the issue. here is the link what I mean: https://github.com/icerockdev/moko-resources EDIT: it's beacuse that library is using this https://github.com/google/ksp/tree/master so I renamed the task to support KSP instead of resources library. Conflict is with KSP

ldobransky commented 1 year ago

I fixed the issue with that code, for another cpu types is need to add the same code: but it fixed the issue, maybe you can update readme, when somebody has issue with ksp, here is the solution: afterEvaluate { tasks { val generateMRiosX64Main by getting val kspKotlinIosX64 by getting kspKotlinIosX64.dependsOn(generateMRiosX64Main) } }

rickclephas commented 1 year ago

Thanks for the update! Actually KMP-NativeCoroutines uses KSP, as far as I can tell moko-resources doesn't use KSP. Anyway looking at your fix the issues seems to be with moko-resources and KSP. Might be worth it to create an issue for moko-resources.