Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
57 views

I'm experiencing the following error with my SwiftData container when running a build: Code=134504 "Cannot use staged migration with an unknown model version." Code Structure - Summary I ...
tishly's user avatar
  • 67
2 votes
1 answer
81 views

I'm working on a SwiftUI app using SwiftData, and I'm very new to both frameworks, and swift in general to be honest. I'm trying to create a webview that embeds a monaco editor that will then send the ...
Fluster.IO's user avatar
0 votes
0 answers
27 views

My application contains two different databases. The first contains information that does not change and will be distributed in the app's bundle. The second contains information that can be edited and ...
Ash's user avatar
  • 9,443
-12 votes
1 answer
249 views

I've been working on a small, SwiftUI/SwiftData app for personal usage. This has been going well until yesterday when I decided I should refactor the SwiftData side of things (split some tables up, ...
Peter M's user avatar
  • 7,591
Best practices
0 votes
9 replies
122 views

I have two SwiftData models like below: @Model final class SDStock { init() {} var id = UUID() var title = "abc" var code = "123456" @Relationship(deleteRule: ....
stephen's user avatar
  • 597
0 votes
1 answer
80 views

I am trying to use a custom property inside a SwiftData model: import SwiftData struct Foo { var name: String } @Model final class Bar { var id: String var name: String var foo: Foo ...
koen's user avatar
  • 5,862
1 vote
2 answers
116 views

I’m new to iOS development and currently learning to persist data using SwiftData. I’m building a very simple to-do list app to understand how local persistence works. However, I’ve hit a wall and ...
Kevin Rodriguez's user avatar
2 votes
1 answer
229 views

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 ...
HáMzà VyNøs's user avatar
1 vote
1 answer
79 views

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 ...
mewi's user avatar
  • 791
0 votes
1 answer
75 views

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 ...
Ryan Sayles's user avatar
  • 3,443
0 votes
0 answers
180 views

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 ...
Mohammed's user avatar
  • 1,504
1 vote
1 answer
116 views

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 ...
Berry Blue's user avatar
  • 16.9k
0 votes
1 answer
125 views

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, ...
Open-Analysis's user avatar
0 votes
0 answers
88 views

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 ...
Jaxon's user avatar
  • 1
1 vote
1 answer
78 views

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). ...
markb's user avatar
  • 1,381
0 votes
1 answer
245 views

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 ...
Neglected Sanity's user avatar
1 vote
1 answer
79 views

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 ...
DeEskalator's user avatar
1 vote
1 answer
76 views

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<...
Nonouf's user avatar
  • 410
1 vote
0 answers
70 views

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 ...
kachmashk's user avatar
0 votes
1 answer
82 views

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 ...
HáMzà VyNøs's user avatar
0 votes
0 answers
44 views

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. ...
markb's user avatar
  • 1,381
1 vote
2 answers
98 views

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 ...
Max B's user avatar
  • 400
4 votes
2 answers
386 views

Summary I have a View Model class, paired with a SwiftUI View, that fetches filtered entries from SwiftData using a ModelActor. I've used SwiftUI's .task(id:) to trigger re-loads in the View Model ...
Neill's user avatar
  • 1,176
2 votes
1 answer
82 views

I am practicing the @Relationship(deleteRule:) feature in SwiftData, and I encounter a crash when deleting a model under certain circumstances. Error message Cannot fulfill future for ...
造船的诺亚's user avatar
0 votes
2 answers
246 views

Hello, I'm trying to create a simple app with inheritance and SwiftData. Unfortunately, I keep getting the same error with this example: Thread 1: Fatal error: Never access a full future backing data ...
hilaprodomo's user avatar
0 votes
0 answers
72 views

A clean Xcode template for a multi-platform document app using SwiftData as storage produces something that looks like this… ... which is obviously daft. See below for how to fix the look, but my ...
Grimxn's user avatar
  • 22.6k
0 votes
0 answers
74 views

In my SwiftData model one of the properties is set to Data? with externalStorage option. So, it means that it will not be stored in the actual database but a reference will be in the database and file ...
john doe's user avatar
  • 9,758
0 votes
1 answer
87 views

Motivation Although recent versions of SwiftData allow us to store enum fields on our models, the underlying database representation is an opaque blob. Sorting and filtering on the field yields a ...
Neill's user avatar
  • 1,176
1 vote
1 answer
211 views

I'm working with SwiftData and trying to replicate behavior similar to what I used to do with CoreData, where I had an extension on NSManagedObjectContext that allowed me to fetch all stored objects, ...
Richard Witherspoon's user avatar
0 votes
2 answers
164 views

I have two selectable lists, the first is populated with Category model objects and the second with Subcategory model objects (which are taken from selected Category value of the first list). When I ...
Ser Pounce's user avatar
  • 14.3k
1 vote
1 answer
367 views

I'm using the swiftdata-sectionedquery package. It basically allows SwiftData to have a SectionedFetchRequest. The problem I am running into is I keep getting this error whenever I try to foreach on ...
Neglected Sanity's user avatar
0 votes
1 answer
165 views

I'm working with SwiftData and trying to share logic across multiple models using protocols and protocol extensions. I’ve created some common protocols like Queryable, StatusRepresentable, and ...
markb's user avatar
  • 1,381
0 votes
0 answers
78 views

Problem Description When using SwiftUI's @Query with SwiftData models, I encountered confusion about reactivity triggering. In certain situations, SwiftUI's reactivity mechanism doesn't work as ...
xinnjie's user avatar
  • 660
0 votes
0 answers
27 views

So, I have this code: import SwiftUI import SwiftData enum MyEnum: String, CaseIterable, Codable { case first = "first case" case second = "second case" case third = &...
Whirlwind's user avatar
  • 12.6k
0 votes
0 answers
46 views

I have this code: import SwiftUI import SwiftData @Model final class Item { @Attribute(.unique) var id = UUID() private(set) var name: String init(name: String) { self.name = ...
Whirlwind's user avatar
  • 12.6k
-1 votes
1 answer
103 views

I have a SwiftData class that I get with @Query private var items: [Item] in a SwiftUI view. Then I pass it to a sub view that passes it to other sub views. What is the best way to pass the class ...
Kitten Apps-Films's user avatar
0 votes
0 answers
114 views

I have some models in my app: [SDPlanBrief.self, SDAirport.self, SDChart.self, SDIndividualRunwayAirport.self, SDLocationBrief.self] SDLocationBrief has a @Relationship with SDChart When I went live ...
PW1990's user avatar
  • 489
0 votes
0 answers
83 views

I have notes app using SwiftData also using CloudKit and the note editor is taking 125% CPU usage. For example this is the note model: @Model Class Note { var title: String = "" var ...
macybooky's user avatar
0 votes
0 answers
32 views

I'm working with SwiftData and trying to filter my data using predicates with a custom enum, but I'm getting an error when the predicate executes: SwiftDataError(_error: SwiftData.SwiftDataError....
MohAliBou's user avatar
  • 265
0 votes
0 answers
86 views

I have 5 Swift Data models: SDPlanBrief, SDAirport, SDChart, SDIndividualRunwayAirport, SDLocationBrief I went live with my first release of the app, with no migration plan or versioned schemas. ...
Paul Wilson's user avatar
3 votes
1 answer
53 views

I'm doing the SwiftData tutorial on Hacking With Swift, and I'm trying one of the challenges which is to add a swipe to delete on a list of related models. I thought I had the right idea, but I'm ...
Ryan Clare's user avatar
-3 votes
1 answer
130 views

Modified to answer concerns appearing in comments. Have the following code: import SwiftUI import SwiftData @main struct Fu: App { var body: some Scene { WindowGroup { ...
Cuse70's user avatar
  • 375
1 vote
0 answers
54 views

Is it possible to convert a NSPersistentHistoryToken to a DefaultHistoryTransaction.TokenType (DefaultHistoryToken)? func subscribeToModelChanges() async { NotificationCenter.default.notifications(...
nicolas Lrr's user avatar
3 votes
1 answer
519 views

I'm trying to migrate over to the Swift 6 language mode, but the biggest issue I'm facing is that any use of SwiftData #Predicate or SortDescriptor results in this warning from the compiler: Type '...
Kevin Olmats's user avatar
0 votes
1 answer
137 views

Edit with minimal reproducible example: @main struct SwiftDataTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Team.self, Player.self ])...
soleil's user avatar
  • 13.3k
0 votes
0 answers
48 views

I am working on a wallet application and I have the models transaction and wallet. Transaction has an extension enum Transaction.Kind which has case deposit and withdrawal. I want to filter the ...
MRhagz's user avatar
  • 1
0 votes
0 answers
105 views

I am developing a Screen Time App for iOS and I am having issues with the ShieldConfigurationExtension (ShieldConfigurationDataSource). I know this extensions is sandboxed but I should be able to read ...
Lukáš Matuška's user avatar
0 votes
1 answer
725 views

So I don't know how to perform SwiftData operations on a background thread. Every time I call my @ModelActor, everything runs on the main thread. I've read online that you must instantiate it on a ...
Xys's user avatar
  • 11.3k
1 vote
1 answer
361 views

I'm currently developping an app, which runs on several devices via TestFlight. Since I am still in an early stage my @Models are subject to change quite frequently. I know that the preferred way of ...
Meyssam's user avatar
  • 941
1 vote
1 answer
162 views

How do you "empty" a database in SwiftData? Something like? func DeleteTestDatabase() { @Environment(\.modelContext) var context do { try context.delete(model: ...
Edward Hasted's user avatar

1
2 3 4 5
17