Hi, first time posting here (sorry if it's a bit long).
I'm using MacBook Pro 16-inch 2021 (M1), macOS 14.5, Xcode 15.4.
I'm somewhat new to SwiftUI + SwiftData, as my macOS development experience is from (way too) many years ago.
I'm developing a SwiftData application, which (so far) is going fairly smoothly. I've reduced my application code to a minimum by commenting out most of it, and I still see the same error message.
I've poked around the Internet for a while now, looking for any hints, but nothing seems to address this specific issue (most talk about other views/types, and in some of those cases the problem is readily apparent).
Here's the (reduced) code for the view in question (it's the primary view in a single-window app; I've barely started so there's not much else there):
// Model/Config.swift
@Model
final class Config: Identifiable {
@Attribute(.unique)
var uuid: UUID = UUID()
// ...
var id: UUID { // for the Identifiable protocol
uuid
}
}
// Views/ContentView.swift
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@Query private var items: [Config]
@State private var theSelection: Config.ID?
var body: some View {
NavigationSplitView {
List(items, selection: $theSelection) { item in
NavigationLink {
Text("UUID: \(item.uuid)")
} label: {
Text(item.uuid.uuidString)
.font(.title2)
}
}
} detail: {
Text("Select an item")
}
}
}
Initially when I run the app, no (existing) items are selected. When I click to choose one of the items (doesn't matter which one), I get the error message from the post title, which I'll repeat here:
List with selection: SelectionManagerBox tried to update multiple times per frame.
It only appears the one time. My item deletion code (not shown above) resets theSelection = nil (by the time I get to this code, the problem has already occurred, so it can't be this). Clicking to make a subsequent selection does not trigger the message again.
Other than this message, the view seems to be operating as expected.
I also tried:
remove selection from List()
problem goes away
change selection type to UUID? and List(id: \.uuid), remove Identifiable and id from Config
problem persists
change selection type to Config? and List(id: \.self)
problem persists
change the List to have just the selection, and use ForEach to build the items' views
problem persists
I do see other messages (which other posts indicate are likely noise), but those are typically coloured yellow ("warning"?). The message I'm posting about is shown in red/purple ("error?").
I'm not too worried for now given that the view seems to be behaving OK otherwise, but my concern is whether this will come back to bite me down the road.
Thanks for your time and attention.