rickclephas / KMP-ObservableViewModel

Library to use AndroidX/Kotlin ViewModels with SwiftUI
MIT License
569 stars 29 forks source link

Cannot inherit from non-open class outside of its defining module #36

Closed humblehacker closed 1 year ago

humblehacker commented 1 year ago

The readme claims that it's possible to subclass my view model in Swift:

class TimeTravelViewModel: shared.TimeTravelViewModel {

... but when I try I get the error Cannot inherit from non-open class 'MyViewModel' outside of its defining module. Any advice?

rickclephas commented 1 year ago

Hi! In order to subclass the ViewModel in Swift you'll need to mark the Kotlin VM as open:

open class TimeTravelViewModel: KMMViewModel()
humblehacker commented 1 year ago

🤦 Calling Kotlin from Swift has muddied my brain! Thanks and sorry for the noise.