onTapGesture unreliable in Big Sur Catalyst apps?

onTapGesture seems like it's incredibly unreliable (eg clicks/taps don't always trigger the onTapGesture closures -- best case is that they're intermittent) in Big Sur for Catalyst apps. The same code runs without problem on iOS 14 and Catalina (again, with Catalyst).

Consider the following basic example:

Code Block
struct ContentView: View {
    @State private var greenOn = false
    @State private var blueOn = false
    var body: some View {
        HStack {
            Rectangle()
                .fill(Color.green)
                .opacity(greenOn ? 1.0 : 0.5)
                .frame(width: 100, height: 100)
                .contentShape(Rectangle())
                .onTapGesture(count: 1, perform: {
                    greenOn.toggle()
                    print("Tapped")
                })
            Rectangle()
                .fill(Color.blue)
                .opacity(blueOn ? 1.0 : 0.5)
                .frame(width: 100, height: 100)
                .onTapGesture(count: 1, perform: {
                    blueOn.toggle()
                    print("Tapped 2")
                })
        }
    }
}


Try to tap the green and blue squares. Best case for me (Big Sur, 11.0.1) is that sometimes onTapGesture will get called.

The easy solution is to convert them to Buttons instead -- but, there are plenty of situations where that isn't ideal (Buttons, for example, don't play nicely with DragGesture).

Is there any way around this bug? Some way to make it work? Or am I stuck until an update restores functionality with Catalina/iOS 14
I am having the same, yep. Very annoying!
I am have the same problem with both Big Sur for catalyst and built for both architectures. It also affects my already published catalyst app.
I had the same problem, and what's worse, when I changed all the buttons to “Button action” form, the “override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) ” in my UIVIEW. doesn't work.

I tried to add a piece of code



.gesture(DragGesture()
.onChanged { value in

}
.onEnded { value in

}
)



and it gets better, but sometimes it still fails to click!





#if targetEnvironment(macCatalyst)

Anytools()

.gesture(DragGesture()
.onChanged { value in

}
.onEnded { value in

}
)

#else

Anytools()


#endif
onTapGesture unreliable in Big Sur Catalyst apps?
 
 
Q