797 questions
1
vote
1
answer
83
views
Why does @Model conformance to PersistentModel and Hashable cross into @MainActor isolation in Swift 6.2?
I’m using Swift 6.2 with MainActor set as the default global actor in my project.
When I create a SwiftData @Model that conforms to a protocol extending PersistentModel, I get actor isolation errors ...
1
vote
1
answer
71
views
Where to put the @Relation(inverse) annotation and what are the benefits? [closed]
Obviously it isn't allowed to put the @Relation(inverse)-annotation on both models. Otherwise one receives an error-message about "Circular Reference".
Therefore, should one put the ...
0
votes
1
answer
60
views
Swift binding to dictionary value
I'm working on an app where I have a view AddMonthView where you put in the monthly balance for financial accounts. That account list is dynamic. So I spent some time trying to figure out how to bind ...
0
votes
0
answers
162
views
Issue with SwiftData inheritance (iOS 26)
Every time I insert a subclass (MYShapeLayer) into the model context, the app crashes with an error:
DesignerPlayground crashed due to fatalError in BackingData.swift at line 908. Never access a full ...
1
vote
1
answer
80
views
How to make a document based app with SwiftData
I have an iOS app that uses SwiftData with @Model types. I’m porting it to macOS and want a document-based app where each window is its own document (like TextEdit). I understand the basic document ...
0
votes
1
answer
98
views
ModelContainers failing to initialize
I need help debugging why my app is failing on hardware trying to initialize the ModelContainer. This is my first app so I may be missing something obvious, but I have two models that I'm trying load, ...
0
votes
0
answers
72
views
Migrating Schema to VersionSchema
I'm very new to SwiftData and have run into an issue where I need to change a datatype in a model. I've attempted to implement a migration plan but my original schema was not of type VersionedSchema ...
1
vote
1
answer
64
views
Reactive global count of model items without loading all records
I need a way to keep a global count of all model items in SwiftData.
My goal is to:
track how many entries exist in the model.
have the count be reactive (update when items are inserted or deleted).
...
0
votes
1
answer
119
views
Set a .modelContext in view's environment to use Query
I started getting this error, and I can't figure out why. I have attached a modelContainer to my main WindowGroup, and I have other views that use the @Query property and they work fine, but for some ...
1
vote
1
answer
56
views
How can I use a model from DocumentGroup alongside one from .modelContainer in Swift Data?
I’m building a document‑based Swift UI app using DocumentGroup with SwiftData. I want:
A document‑scoped model (Gate) that is persisted inside a file
An app‑scoped model (User) that is stored in the ...
0
votes
1
answer
69
views
Predicates with generics
I’m trying to use Predicate with generics but I keep getting the following compilation error :
Cannot convert value of type 'PredicateExpressions.Equal<PredicateExpressions.ConditionalCast<...
1
vote
0
answers
61
views
Sync not working for independent watchOS app using CloudKit and SwiftData
I'm working on an independent watchOS app and I was looking for the best solution to persist data locally and have an online sync with the iCloud storage.
I've found out about the SwiftData which is ...
0
votes
1
answer
72
views
SwiftData @Model not persisting across app launches (works only in memory)
I’m using SwiftData in a macOS app (Xcode 16, macOS 15, Swift 6).
My models and managers compile fine, inserts/deletes work at runtime, but nothing persists after relaunch — all data is gone.
Here’s a ...
0
votes
0
answers
39
views
Swift 6: “Main actor-isolated conformance of FeelingType to Encodable cannot be used in nonisolated context” with SwiftData @Model [duplicate]
I’m migrating a small SwiftData model from Swift 5 to Swift 6. The same code compiles under Swift 5, but with Swift 6 it fails when the @Model macro expands a property whose type conforms to Codable.
...
1
vote
2
answers
82
views
SwiftUI TextField input is super laggy for SwiftData object
I have a SwiftUI View where I can edit financial transaction information. The data is stored in SwiftData. If I enter a TextField element and start typing, it is super laggy and there are hangs of 1-2 ...