SwiftUI Gestures prevent scrolling with iOS 18

I added gesture support to my app that supports iOS 16 and 17 and have never had issues with it.

However, when I compiled my app with Xcode 16 I immediately noticed a problem with the app when I ran it in the simulator. I couldn't scroll up or down. I figured out it’s because of my gesture support.

My gesture support is pretty simple.

        let myDragGesture = DragGesture()
            .onChanged { gesture in
                self.offset = gesture.translation
            }
            .onEnded { _ in
                    if self.offset.width > threshold {
                       ...some logic
                    } else if self.offset.width < -threshold {
                       ...some other logic
                    }
                              
                logitUI.debug("drag gesture width was \(self.offset.width)")
                self.offset = .zero
            }

If I pass nil to .gesture instead of myDragGesture then scrolling starts working again.

Here’s some example output when I’m trying to scroll down. These messages do NOT appear when I run my app on an iOS 16/17 simulator with Xcode 15.

  • drag gesture width was 5.333328
  • drag gesture width was -15.333344
  • drag gesture width was -3.000000
  • drag gesture width was -24.333328
  • drag gesture width was -30.666656

I opened FB14205678 about this.

SwiftUI Gestures prevent scrolling with iOS 18
 
 
Q