Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

UIStateKs not synchronized with UIState class #97

@aleksey-ho

Description

@aleksey-ho

I have this code that works in debug environment, but crashes in testflight.

    private val _purchaseResult = MutableStateFlow<UIState<UserPremium>>(UIState.Empty)
    val purchaseResult = _purchaseResult.cStateFlow()

in BasePurchaiseScreen.swift:

struct BasePurchaiseScreen<Content> : View where Content : View {
  @StateObject var vm = PurchaseVM()
...
extension PurchaseVM {
  var purchaseResultBind: UIStateKs<UserPremium> {
    get {
      return self.state(
        \.purchaseResult,
         equals: { $0 === $1 },
         mapper: { UIStateKs($0) }
      )
    }
  }
}

It did work, but somehow it started crashing when I call vm.purchaseResultBind with error:

Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001a0ab58c0
0 libswiftCore.dylib 0x398c0 assertionFailure(:_:file:line🎏) + 264
1 myapp 0x7c850 MPLPurchaseVM.purchaseResultBind.getter + 80 (BasePurchaiseScreen.swift:80)
2 myapp 0x7bb48 closure #1 in BasePurchaiseScreen.body.getter + 42 (BasePurchaiseScreen.swift:42)
3 SwiftUI 0x181e58 OUTLINED_FUNCTION_1147 + 1244
4 myapp 0x7b35c BasePurchaiseScreen.body.getter + 53 (BasePurchaiseScreen.swift:53)
5 myapp 0x7cad8 protocol witness for View.body.getter in conformance BasePurchaiseScreen + 4366256856 (:4366256856)
6 SwiftUI 0x202528 dynamic_cast_existential_0_superclass_conditional + 24428
7 SwiftUI 0x24d738 -[UIScrollView(SwiftUI) _swiftui_adjustsContentInsetWhenScrollDisabled] + 31980
8 SwiftUI 0x24b3bc -[UIScrollView(SwiftUI) _swiftui_adjustsContentInsetWhenScrollDisabled] + 22896
9 SwiftUI 0x1fdb30 dynamic_cast_existential_0_superclass_conditional + 5492
10 AttributeGraph 0x9010 AG::Graph::UpdateStack::update() + 512
11 AttributeGraph 0x8bfc AG::Graph::update_attribute(AG::data::ptrAG::Node, unsigned int) + 424
12 AttributeGraph 0x2cc0 AG::Graph::input_value_ref_slow(AG::data::ptrAG::Node, AG::AttributeID, unsigned int, unsigned int, AGSwiftMetadata const*, unsigned char&, long) + 720
....

I also found "MultiPlatformLibrarySwift/myapp_shared.swift:37: Fatal error: UIStateKs not synchronized with UIState class" message in logs from generated UIStateKs.

Any idea to fix this crash?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions