r/SwiftUI • • 18h ago Bravo

A checklist I use when a SwiftUI List or ScrollView stutters

18 Upvotes

Most SwiftUI scroll jank I've debugged came from a short list of causes, not from SwiftUI being slow. Here's the order I check them in. Curious what others would add.

  1. Unstable identity. `ForEach(items, id: \.self)` on values that aren't unique, or ids created inside the view (`UUID()` in `body`), make SwiftUI treat rows as new on every update. Use a stable id from your model.
  2. Work inside `body`. Date formatters, sorting, filtering or image decoding in `body` run on every re-render. Move them into the model or cache the result.
  3. Observing too much. With `@Observable`, a view re-renders for the properties it reads. If every row reads half of a big shared model, one change can invalidate far more rows than you expect. Give each row only what it needs.
  4. Conditional modifiers that swap view types. An `if` that wraps a row in different modifiers changes its structural identity and resets its state. Prefer value-based modifiers, like `.opacity(isHidden ? 0 : 1)`.
  5. Images. Full-size images decoded on the main thread will drop frames. Downsample to the size you actually display.

Before changing anything, I profile on a real device with a release build, using Instruments (the SwiftUI template plus Time Profiler). `Self._printChanges()` in `body` is also handy for seeing why a view re-rendered. Debug builds and the simulator can point you at the wrong problem.

What's the most surprising cause of scroll jank you've run into?


r/SwiftUI • • 4h ago

Buttons in .confirmationDialog have a significant delay when triggered

2 Upvotes

When tapping a button in a .confirmationDialog (at least one tied to a .bottomBar ToolbarItem), a ridiculously long delay — about a full second after the dialog closes — occurs before the action triggers. This issue is present in some of Apple's apps, including Reminders, Shortcuts, and Notes, but notably not in the Photos app. It also occurs for .alert, though to a lesser degree. How can I eliminate this, preferably without dropping down to UIKit?

The problem has been present since iOS 26. I haven't checked whether it existed before then.

Example code:

struct ContentView: View {
     private var confirmationDialogPresented = false
     private var colorToggled = false
    
    var body: some View {
        NavigationStack {
            Color(colorToggled ? .blue : .red)
                .ignoresSafeArea()
                .toolbar {
                    ToolbarItem(placement: .bottomBar) {
                        Button("Placeholder", systemImage: "square") {
                            confirmationDialogPresented = true
                        }
                        .confirmationDialog("Placeholder", isPresented: $confirmationDialogPresented) {
                            Button("Placeholder") {
                                colorToggled.toggle()
                            }
                        }
                    }
                }
        }
    }
}

#Preview {
    ContentView()
}

r/SwiftUI • • 9h ago

We rewrote the entire Rust WGPU in Swift, and it looks fantastic. I call it SAGA

Thumbnail gallery
2 Upvotes

r/SwiftUI • • 6h ago

Real Ubuntu Linux in an iPad/iPhone code editor, now live on the App Store

Post image
1 Upvotes

I'm the solo dev of Pad Code AI. Version 3.3 runs real Ubuntu (arm64) right on the device, with no server and no account. You get bash, apt and about 60 tools (Python, C/C++, Node, Go, Rust, Java…) that you download once and use offline, plus a real debugger, LaTeX to PDF and live web previews.

The core is free.

https://apps.apple.com/app/id6774398897

Happy to answer any questions!


r/SwiftUI • • 8h ago

Recreated the Trip.com splash screen animation in SwiftUI

1 Upvotes

I really liked the Trip launch animation, so I recreated it. The logo's letters get swallowed by the orange dot, the dot stretches into a streak, and a circle sweeps in to reveal your first screen.

Source: https://repgem.com/trip-splash-ios

Would love your feedback!

Inspired by the Trip.com app. The code is original and not affiliated with them.


r/SwiftUI • • 12h ago

Promotion (must include link to source code) A SwiftUI answer balloon beside selected text in any Mac app (source included)

Post image
1 Upvotes

I make Glossbeam, an open-source macOS app that shows an explanation beside selected text. The screenshot shows the UI problem: the answer needs to sit close enough to the selection to make their relationship clear, while leaving room to keep reading. I’d be interested in how other Mac developers handle positioning near a display edge. The Mac and Shared source and Xcode build instructions are here: https://github.com/YasserShkeir/glossbeam-open.


r/SwiftUI • • 18h ago

News The iOS Weekly Brief: Issue #88. macOS on iPad, iOS 27.3 beta 2, unknown enum cases, Xcode MCP vs xcodebuild, SwiftUI List internals, container values, drag and drop reordering in SwiftUI, iPhone Duo layouts, and Black Friday deals

Thumbnail
iosweeklybrief.com
1 Upvotes