Skip to main content
Filter by
Sorted by
Tagged with
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
0 votes
1 answer
246 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
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
63 views

I don't know how do I write a migration plan for this if it's required, is this a lightweight migration or a complex migration @Model class ParkModel { var items: [String]? init(items: [...
Nishant Minerva's user avatar
1 vote
1 answer
198 views

Definitely one of the stranger quirks of SwiftData I've come across. I have a ScriptView that shows Line entities related to a Production, and a TextEnterScriptView that’s presented in a sheet to ...
The-Wolf's user avatar
  • 135
1 vote
0 answers
127 views

I'm developing an iOS app with SwiftData and modern Swift concurrency using ModelActors. In my app I have two distinct model containers: Main Container: Holds UI‑relevant models. Queue Container: ...
D.Schall's user avatar
1 vote
1 answer
588 views

SwiftData delete isn't working, when I attempt to delete a model, my app crashes and I get the following error: SwiftData/PersistentModel.swift:359: Fatal error: Cannot remove My_App.Model2 from ...
The-Wolf's user avatar
  • 135
2 votes
1 answer
519 views

I've been stuck on this for the past week and I'm asking here out of desperation. I have a project using Swift 5, and I recently enabled “Strict Concurrency Checking” to “Complete” so I can slowly ...
Ryan Kanno's user avatar
0 votes
0 answers
19 views

New to data persistence and I'm trying to improve the performance of an app that uses SwiftData. I profiled the app in Instruments, and I saw a lot of data / relationship faults. What are they and how ...
RRR's user avatar
  • 315
0 votes
1 answer
102 views

I think my understanding of ModelActor is wrong... I thought ModelActors are used to perform database actions that we don't want to run on the main thread and lock up the UI. Are there any specific ...
RXP's user avatar
  • 707
0 votes
2 answers
548 views

So, since I updated to Xcode 16.1 and iOS 18, my SwiftData project who relies on autosave doesn't work as expected. Indeed, it works but only after a delay, around 30 seconds. So if I add something to ...
Jintae's user avatar
  • 53
3 votes
1 answer
315 views

Hello, I'm trying to unit test a SwiftData Model, but I'm facing a weird situation and couldn't find an answer to the problem. The first solution I'll show you does not work, the second one does. ...
Jintae's user avatar
  • 53
-1 votes
2 answers
222 views

import SwiftUI import SwiftData struct ItemListView: View { @Bindable var luggage: Luggage @Environment(\.modelContext) var modelContext @State private var selectedItem: Item? ...
Sebbie_O's user avatar
1 vote
0 answers
90 views

I’m using Swift Data and CloudKit, with a private container. When developing my understanding is that you should have a target with com.apple.developer.icloud-container-environment key set to “...
Alistair Cooper's user avatar
2 votes
2 answers
334 views

I have 2 models in my app, fist (ModelA) is working fine - data is persistent no matter how many times I restart app on the simulator, but the second (ModelB) sometimes losts it data and I see errors ...
moonvader's user avatar
  • 21.3k
0 votes
0 answers
38 views

I am working on migrating my app to SwiftData and testing out some things. I have a custom made toolbar that shows among other things the various objects in a @Model. When I drag one of these to the ...
Jimbo17's user avatar
  • 13
0 votes
0 answers
208 views

We have an app that uses two SwiftData models in a one-to-many relationship to Log Data given by the user. In the first model we have a date property and an array. Yhe other model is using the one to ...
Yianni's user avatar
  • 1
1 vote
1 answer
1k views

I need some help with SwiftData. I want to have a few instances of one of my SwiftData classes created only the first time the app opens. These instances should be created once when the app opens for ...
Serafin's user avatar
  • 21
3 votes
2 answers
4k views

In my Swift app I had a data model which I needed to remodel. After that, at the root level of my app, the code crashes when trying to load the ModelContainer, no matter what. The error is a huge ...
CameronBaba's user avatar
0 votes
1 answer
368 views

The context is to create a model instance in SwitfData and return it. This model as a unique attribute (defined by @Attribute(.unique)). The application runs fine the first time but on the second run, ...
OlivierM's user avatar
  • 3,312
3 votes
0 answers
586 views

I have two SwiftData models, with a many-to-many relationship between them: @Model class Movie { var name: String? @Relationship(deleteRule: .nullify, inverse: \Actor.movies) var actors: [...
RRR's user avatar
  • 315
0 votes
0 answers
108 views

I created a small SwiftData project, hosting a list with an .onDelete modifier. In order to filter the list I extracted the list into a separate ListView and set the filter using the init method. But ...
Mat Fetsch's user avatar
0 votes
3 answers
673 views

I'm building out a SwiftData model in the preliminary stages of app development. I'm using test-driven development (tdd) to iterate on the model and iron out kinks prior to integrating the model into ...
pkamb's user avatar
  • 35.5k
0 votes
0 answers
86 views

New to SwiftData (and Core Data). In my app, I'd like to keep track of a selected item from a list of items, so it's available when the app is relaunched: @Model class Person { var name: String ...
RRR's user avatar
  • 315
0 votes
2 answers
1k views

This error only appears in Preview - I am able to run my app fine. I have a modification sheet that I want to build out in SwiftUI but the preview will not work which is putting a damper on my ...
Taylor Hartman's user avatar
0 votes
0 answers
1k views

I have a ChildView that you can access via NavigationLink and that will display in a NavigationSplitView’s detail pane. NavigationSplitView { ListView() } detail: { } And .navigationDestination(for:...
Barrrdi's user avatar
  • 1,211
0 votes
1 answer
709 views

In a UIKit-based app where I'm integrating SwiftUI: class SwiftDataManager { static let shared = SwiftDataManager() private init() {} var container: ModelContainer? func ...
soleil's user avatar
  • 13.3k
7 votes
1 answer
3k views

I have a SwiftData @Query in a LazyVStack, works nicely, updates on every model change, even if I make changes in relations only. But I also have a long running task (~3 sec), so I created a @...
Geri Borbás's user avatar
  • 16.7k
2 votes
1 answer
340 views

I can create all kinds of predicates fine, but I'm not sure what can I use for implement "ENDSWITH"? extension Filter { var predicate: Predicate<WordModel>? { switch self {...
Geri Borbás's user avatar
  • 16.7k
1 vote
1 answer
385 views

Let's say in SwiftUI / SwiftData, we have two models: @Model final class Thing1 { private var things:[Thing2] func deleteThing(thing: Thing2) { things.removeAll(where: {$0....
Nerdy Bunz's user avatar
  • 7,743