Crash on iOS 13 when tap a button in the sheet

Hello. Currently, I'm trying to migrate my app to the composable architecture and I faced a problem with a crash that reproducible only for ios 13. In my SwiftUI view when the user taps on a button it will present a sheet. There a few buttons in this sheet and when tap any on it the app just crashed.

My code

Any help will be appreciated

@Bredox Is there more of a stack trace around the failure? Is it also possible to include a full, compiling project? The gist seems incomplete (it's missing types like UserState, UserAction, etc.)

@stephencelis Unfortunately, I cannot provide the full source code. I've added a UserCore to the gist and here a stack trace of the crash.

Main Thread - Crashed

    libswiftCore.dylib
    swift_getGenericMetadata
    E-TicketsTCA
    0x100ddc000 + 16170880
    E-TicketsTCA
    0x100ddc000 + 16172184
    libswiftCore.dylib
    static (extension in Swift):Swift.Optional<A where A: Swift.Equatable>.== infix(A?, A?) -> Swift.Bool
    E-TicketsTCA
    0x100ddc000 + 11446144
    E-TicketsTCA
    0x100ddc000 + 11446444
    libswiftCore.dylib
    static (extension in Swift):Swift.Optional<A where A: Swift.Equatable>.== infix(A?, A?) -> Swift.Bool
    E-TicketsTCA
    0x100ddc000 + 1872680
    E-TicketsTCA
    0x100ddc000 + 1873068
    E-TicketsTCA
    0x100ddc000 + 22198676
    Combine
    reabstraction thunk helper <A><A1 where A: Combine.Publisher, A1: Combine.Subscriber, A.Failure == A1.Failure, A.Output == A1.Input> from @escaping @callee_guaranteed (@in_guaranteed A.Output, @in_guaranteed A.Output) -> (@unowned Swift.Bool) to @escaping @callee_guaranteed (@in_guaranteed A.Output, @in_guaranteed A.Output) -> (@out Swift.Bool)
    Combine
    Combine.Publishers.RemoveDuplicates.(Inner in _0DC1C469F64165A7EE9727222098AB38).receive(newValue: A.Output) -> Combine.PartialCompletion<A.Output?, A.Failure>
    Combine
    Combine.FilterProducer.receive(B) -> Combine.Subscribers.Demand
    Combine
    protocol witness for Combine.Subscriber.receive(A.Input) -> Combine.Subscribers.Demand in conformance Combine.FilterProducer<A, B, C, D, E> : Combine.Subscriber in Combine
    Combine
    Combine.AnySubscriberBox.receive(A.Input) -> Combine.Subscribers.Demand
    Combine
    Combine.CurrentValueSubject.Conduit.offer(A) -> ()
    Combine
    Combine.CurrentValueSubject.send(A) -> ()
    Combine
    function signature specialization <Arg[0] = Owned To Guaranteed> of Combine.CurrentValueSubject.value.setter : A
    Combine
    Combine.CurrentValueSubject.value.modify : A with unmangled suffix ".resume.0"
    E-TicketsTCA
    0x100ddc000 + 21945076
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 21943032
    E-TicketsTCA
    0x100ddc000 + 21946584
    E-TicketsTCA
    0x100ddc000 + 21945048
    E-TicketsTCA
    0x100ddc000 + 22274588
    E-TicketsTCA
    0x100ddc000 + 22276560
    E-TicketsTCA
    0x100ddc000 + 17959860
    SwiftUI
    SwiftUI.PrimitiveButtonStyleConfiguration.trigger() -> ()
    SwiftUI
    partial apply forwarder for SwiftUI.PrimitiveButtonStyleConfiguration.trigger() -> ()
    SwiftUI
    closure #1 () -> () in SwiftUI.PressableGestureCallbacks.dispatch(phase: SwiftUI.GesturePhase<A>, state: inout Swift.Bool) -> () -> ()?
    SwiftUI
    reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ())
    SwiftUI
    reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out ()) to @escaping @callee_guaranteed () -> ()
    SwiftUI
    reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> (@out ())
    SwiftUI
    static SwiftUI.Update.dispatchActions() -> ()
    SwiftUI
    static SwiftUI.Update.end() -> ()
    SwiftUI
    SwiftUI.EventBindingManager.send([SwiftUI.EventID : SwiftUI.EventType]) -> ()
    SwiftUI
    SwiftUI.UIKitGestureRecognizer.(send in _062C14327F4C9197D92807A7F4DF7F3B)(touches: Swift.Set<__C.UITouch>, event: __C.UIEvent, phase: SwiftUI.EventPhase) -> [SwiftUI.EventID]
    SwiftUI
    SwiftUI.UIKitGestureRecognizer.touchesEnded(_: Swift.Set<__C.UITouch>, with: __C.UIEvent) -> ()
    SwiftUI
    merged @objc SwiftUI.UIKitGestureRecognizer.touchesBegan(_: Swift.Set<__C.UITouch>, with: __C.UIEvent) -> ()
    UIKitCore
    -[UIGestureRecognizer _touchesEnded:withEvent:]
    UIKitCore
    -[UITouchesEvent _sendEventToGestureRecognizer:]
    UIKitCore
    -[UIGestureEnvironment _updateForEvent:window:]
    UIKitCore
    -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:]
    UIKitCore
    -[UIGestureEnvironment _updateForEvent:window:]
    UIKitCore
    -[UIWindow sendEvent:]
    UIKitCore
    -[UIApplication sendEvent:]
    UIKitCore
    __dispatchPreprocessedEventFromEventQueue
    UIKitCore
    __handleEventQueueInternal
    UIKitCore
    __handleHIDEventFetcherDrain
    CoreFoundation
    __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
    CoreFoundation
    __CFRunLoopDoSource0
    CoreFoundation
    __CFRunLoopDoSources0
    CoreFoundation
    __CFRunLoopRun
    CoreFoundation
    CFRunLoopRunSpecific
    GraphicsServices
    GSEventRunModal
    UIKitCore
    UIApplicationMain
    libswiftUIKit.dylib
    UIKit.UIApplicationMain(Swift.Int32, Swift.UnsafeMutablePointer<Swift.UnsafeMutablePointer<Swift.Int8>>?, Swift.String?, Swift.String?) -> Swift.Int32
    E-TicketsTCA
    0x100ddc000 + 276660
    E-TicketsTCA
    0x100ddc000 + 276524
    E-TicketsTCA
    0x100ddc000 + 286588
    libdyld.dylib
    start

Today I found that the app crashing only if I build and run it from Xcode. I made a build for testflight install it and there are no crashes.

I solved the issue by adding an ID to my AppState which is the main state of my application

struct AppState: Equatable {
    let id = UUID()
    var userState: UserState?
    var loginState: LoginState?
}
Terms of Service

Privacy Policy

Cookie Policy