CodexBloom - Programming Q&A Platform

SwiftUI List performance implementing large datasets in iOS 17

👀 Views: 95 💬 Answers: 1 📅 Created: 2025-06-11
swiftui ios performance list xcode swift

I've been working on this all day and I'm working on a personal project and I've been struggling with this for a few days now and could really use some help. I'm experiencing important performance optimization when displaying large datasets in a `List` using SwiftUI on iOS 17. My dataset consists of around 10,000 items, and I notice that scrolling becomes extremely laggy and unresponsive, even when the list is not updating dynamically. I've tried implementing pagination by loading a subset of data at a time, but the stuttering continues even with just a few hundred items loaded at once. Here's a simplified version of my implementation: ```swift struct ContentView: View { let items: [String] var body: some View { List(items, id: \ .self) { item in Text(item) } .listStyle(PlainListStyle()) } } ``` I've verified that the `items` array is not being modified in a way that would trigger unnecessary updates, and I'm using the `.listStyle(PlainListStyle())`. However, I still see excessive CPU usage when scrolling through the list. I've also tried wrapping the `List` inside a `ScrollView` to see if it would help, but it didn’t improve performance. Additionally, I'm using the latest version of Xcode and have tested this on both an iPhone 12 and iPhone 14 with iOS 17.0.1. Is there a more efficient approach to rendering large datasets in a SwiftUI `List`, or are there any known issues with this version that could be causing these performance bottlenecks? Thanks in advance! I'm working on a web app that needs to handle this. What am I doing wrong? This is happening in both development and production on macOS. What would be the recommended way to handle this?