Xcode 16 SwiftUI List Fast Scrolling Issue

Hi! When building my app using Xcode 16, fast scrolling (using scrollViewProxy.scrollTo) a list would result in items not appearing even when scrolling stopped. This does not happen when the app is built with Xcode 15, even on iOS 18.

I'm also getting this error in the logs: List failed to visit cell content, returning an empty cell. - SwiftUICore/Logging.swift:84 - please file a bug report.

Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

Hello,

I have also been experiencing the same issue when trying to implement a section index for a List in SwiftUI.

Please see below for a simple example from a test project (created with the default Xcode 16 build settings, no other changes) that reproduces the same issue outlined by the OP.

import SwiftUI

struct ContentView: View {
    
    let sections: [String] = ["#", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
    
    var body: some View {
        ScrollViewReader { proxy in
            ZStack {
                List {
                    ForEach(sections, id: \.self) { section in
                        Section(section) {
                            ForEach(0...25, id: \.self) { _ in
                                Text("Hello, \(section)!")
                            }
                        }
                    }
                }
                .listStyle(.plain)
                .padding(.trailing)
                HStack {
                    Spacer()
                    SectionIndexTitles(proxy: proxy, titles: sections)
                }
            }
        }
        .scrollIndicators(.never)
    }
}

struct SectionIndexTitles: View {
    let proxy: ScrollViewProxy
    let titles: [String]
    @GestureState private var dragLocation: CGPoint = .zero
    
    var body: some View {
        VStack {
            ForEach(titles, id: \.self) { title in
                Text(title)
                    .font(.footnote)
                    .fontWeight(.semibold)
                    .background(dragObserver(title: title))
            }
        }
        .padding(.horizontal, 2.5)
        .gesture(DragGesture(minimumDistance: 0, coordinateSpace: .global).updating($dragLocation, body: { value, state, _ in
            state = value.location
        }))
    }
    
    func dragObserver(title: String) -> some View {
        GeometryReader { geometry in
            dragObserver(geometry: geometry, title: title)
        }
    }
    
    func dragObserver(geometry: GeometryProxy, title: String) -> some View {
        if geometry.frame(in: .global).contains(dragLocation) {
            DispatchQueue.main.async {
                proxy.scrollTo(title, anchor: .top)
            }
        }
        return Rectangle().fill(Color.clear)
    }
}

Thank you, Alex

Xcode 16 SwiftUI List Fast Scrolling Issue
 
 
Q