Questions tagged [swiftdata]
SwiftData is a Swift-based Apple framework for managed persistence. It combines CoreData persistence technology with Swift’s modern concurrency features.
swiftdata
300
questions with no upvoted or accepted answers
12
votes
0
answers
723
views
Sharing SwiftData with iCloud users
has anyone figured out how to use swiftdata in SwiftUI with CloudKit to share data among other users and set permissions? Thank you!
I checked apple’s documentation along with the internet in general. ...
6
votes
1
answer
298
views
How to change entity name in SwiftData
I'm working with SwiftData in coredata project.
I have coredata models (Event, EventDate, Lecture), and convert to swiftdata model using Model macro.
enum V3Schema: VersionedSchema {
static var ...
6
votes
1
answer
584
views
Unique properties of SwiftData Models when using CloudKit
Unfortunately the .unique attribute is not available for SwiftData model properties when using CloudKit.
Is there a best practice to setup a constraint like this for my own models?
For the local DB it'...
5
votes
0
answers
750
views
Is it possible to have a single data Entity using SwiftData? (non-array, like persistent app settings)
I would like to have a settings entity with SwiftData. I would like it to store my active entity that the user was working with when they last used the app, plus a few other settings that I would like ...
5
votes
0
answers
753
views
SwiftData sort or filter enum property
Now that SwiftData can correctly store enums in our models, I am now having difficulties trying to filter or sort on that property.
For example
status is an enum
enum Status: String, Codable, ...
5
votes
1
answer
1k
views
SwiftData how to form a search predicate with a one to many model
I am working in Xcode 15 (beta) migrating to SwiftData and am having a hard time figuring out how to form a predicate in my one to many model. The desired result is to return a query that returns ...
4
votes
0
answers
259
views
Is it possible to add a new optional property to a Swift Data Model without having to do a migration?
I already tried and it works without a problem (in Test Flight), but I want to know if its a good idea for future cases to do the same on a production environment and why.
I also use cloud kit to ...
4
votes
0
answers
430
views
SwiftData Predicate with Many to Many Relationship
I'm building a Photo managing app that uses tags to help filter images. I decided to use SwiftData since it makes syncing images via CloudKit super easy. However, I'm having trouble fetching photos ...
4
votes
0
answers
493
views
SwiftData - Predicate does not support keypaths with multiple components
I have [Word] to [Folder], and Word to Card relationships. I can fetch all words for folder, but i can't fetch all cards for folder. It says Predicate does not support keypaths with multiple ...
4
votes
1
answer
679
views
Xcode 15, iOS 17 - Archive Failed - File name too long
Working on Xcode 15 GA. I'd like to archive my new iOS 17 project, which works properly on iOS and macOS (includes SwiftData library, new WidgetKit extension and StoreKit). However, when I'm trying to ...
4
votes
0
answers
572
views
SwiftData inverse Relationship stop working in Xcode 15 beta 7
This approach works before Xcode 15 beta 7:
@Model
final class Item {
var name: String
@Relationship(inverse:\Note.item) var notes: [Note]
init(name: String = "Item name") {
...
4
votes
0
answers
530
views
SwiftData - 'self' used in property access 'persistentBackingData' before 'super.init' call
I was trying to set a class to be a persistent data source using @Model annotation, and somehow this happened:
The code above is generated by the compiler and the error is located in it.
Here is my ...
4
votes
1
answer
3k
views
Setting up SwiftData with iCloud share - difference to Core Data
How to set up the sharing mechanism with SwiftData (Sharing between users)?
Are there any differences to the tutorials that can be found on this topic for iCloud + Core Data?
When looking at the ...
4
votes
0
answers
971
views
Lightweight Migration Issues in SwiftData
I am trying to run a lightweight migration in which I am changing the name of a model property from name to title. The database is already populated with few records. Those records must be preserved.
...
4
votes
0
answers
893
views
SwiftData and correct setup for AppGroup
I have Xcode 15 Beta 2 and I am using SwiftData for my new app that is going to have also an extension and Apple Watch companion app.
At the moment I am configuring the iOS/iPadOS app as following:
My ...