is there anyway to access the SwiftUI framework from multiplatform code? i want my iOS viewmodel to ...
w
is there anyway to access the SwiftUI framework from multiplatform code? i want my iOS viewmodel to extend
ObservableObject
but it seems like I may not be able to access SwiftUI since there are no obj-c bridging headers edit: change compose to swiftui - too much android on my mind
t
No dice here. Since Combine is Swift only, you're not going to be able to do this.
w
maybe i'll write some Swift code gen stuff to automatically wrap my shared viewmodels to help me here. not for today though. thanks @Thomas Myrden!
t
You should be able to pretty easily write some custom code to bridge a delegate pattern or similar to a pub sub pattern though. Create a protocol with an extension that does this for you or something along those lines. No sweat, good luck!
d
m
William I thought about it a lot too, basically you have 2 options: • Introduce useCases and implement viewmodels per target (https://www.marcogomiero.com/posts/2020/kmm-shared-app-architecture/) • Keep everything as it is and only for IOS introduce ViewModelWrappers and extend from
ObservableObject
and keep your view model in it. I use second approach since I didn’t want to duplicate viewmodels per platform. you can check this thread too: https://kotlinlang.slack.com/archives/C3PQML5NU/p1604234332223200
👍 2