Search results for

“SwiftData inheritance relationship”

4,986 results found

Post

Replies

Boosts

Views

Activity

Reply to Driver Activation failure error code 9. Maybe Entitlements? Please help
First, I wanted to apologize for not replying for a full month, as well as thank you very much for your reply. I was pulled away from this project for a couple weeks, and when I got back I was still spinning my wheels getting the driver installed. Not a problem at all. It was 67 characters and, apparently the maximum is 63. Seems like an arbitrarily short max in this day and age, and you'd think both XCode and the Developer Portal would catch that, but that's what it was. Sigh... I'm sorry I didn't think of that, as I'm aware of that limitation and actually posted about it here. FYI, you should also be aware of the version number limitation described here, which is another arbitrary restriction the kernel enforces. So, on to my current problem. The driver installs... but doesn't load. Probably because it's not matching. So I'm going to give more detailed information in the hope you can help me with this. If you haven't seen it already, I have a post here that does an extended run down of the matching and load
Topic: App & System Services SubTopic: Drivers Tags:
Mar ’26
Reply to CloudKit Sync Stalls During Initial Large Data Hydration on New Device (SwiftData Local-First Architecture)
For a large dataset, the initial synchronization with CloudKit, which can happen in several cases, including on-boarding a new device, can indeed be slow, or even failed. A similar issue was discussed in this thread as well. Depending on your concrete use case, you might address the issue in the following way: Have your app functional before the dataset is fully synchronized. Synchronize the data in batches in the background, until the whole data set is done. As an example, an email app that is just installed on a new device allows users to compose a new email, while synchronizing existing emails in the background. When using the CloudKit framework, you control what kind and amount of data to be synchronized with CloudKit, and hence can implement the strategy, though the implementation can be quite involved. Now that you are using SwiftData + CloudKit integration, NSPersistentCloudKitContainer takes care the synchronization process. I don't really see anything to work around or mitigate the issue in
Mar ’26
Access Relationship value from deleted model tombstone in SwiftData.
I’m developing an app using SwiftData. In my app, I have two models: User and Address. A user can have multiple addresses. I’m trying to use SwiftData History tracking to implement some logic when addresses are deleted. Specifically, I need to determine which user the address belonged to. From the documentation, I understand that you can preserve attributes from deleted models in a tombstone object using @Attribute(.preserveValueOnDeletion). However, this isn’t working when I try to apply this to a relationship value. Below is a simplified example of my attempts so far. I suspect that simply adding @Attribute(.preserveValueOnDeletion) to a relationship isn’t feasible. If that’s indeed the case, what would be the recommended approach to identify the user associated with an address after it has been deleted? Thank you. @Model class User { var name: String @Relationship(deleteRule: .cascade, inverse: Address.user) var addresses: [Address] = [] init(name: String) { sel
1
0
91
Mar ’26
SwiftData Unidirectional Relationships
Hi everyone I would like to achieve having unidirectional relationships in my SwiftData project (which I believe is possible: https://developer.apple.com/documentation/updates/swiftdata?changes=_9) but I'm afraid I'm struggling to overcome the errors I'm experiencing. For example, I have the following models: @Model final class Quota { @Attribute(.unique) var id: UUID var allowance: Int @Relationship(inverse: nil) var fish: Fish init(id: UUID = UUID(), fish: Fish, allowance: Int) { self.id = id self.fish = fish self.allowance = allowance } } @Model final class Fish { @Attribute(.unique) var id: Int var name: String init(id: Int, name: String) { self.id = id, self.name = name } } However, when I attempt to save a quota as so: let quota: Quota = .init(fish: Fish(id: 2, name: Salmon), allowance: 50) modelContext?.insert(quota) try save() I keep getting the following error: SwiftData.DefaultStore save failed with error: Error Domain=NSCocoaErrorDomain Code=1570 %{PROPERTY}@ is
1
0
185
Mar ’26
CloudKit Sync Stalls During Initial Large Data Hydration on New Device (SwiftData Local-First Architecture)
Hi everyone, I’m facing an issue with CloudKit sync getting stuck during initial device migration in my SwiftData-based app. The app follows a local-first architecture using SwiftData + CloudKit sync, and works correctly for: ✔ Incremental sync ✔ Bi-directional updates ✔ Small datasets However, when onboarding a new device with large historical data, sync becomes extremely slow or appears stuck. Even after two hours data is not fully synced. ~6900 Transactions 🚨 Problem When installing the app on a new iPhone and enabling iCloud sync: • Initial hydration starts • A small amount of data syncs • Then sync stalls indefinitely Observed behaviour: • iPhone → Mac sync works (new changes sync back) • Mac → iPhone large historical migration gets stuck • Reinstalling app / clearing container does not resolve issue • Sync never completes full migration This gives the impression that: CloudKit is trickling data but not progressing after a certain threshold. The architecture is: • SwiftData lo
1
0
156
Mar ’26
Sharing all container content
I've understood that SwiftData is not abled to share the whole content of a cloudkit database. So I'm trying to rewrite everything. Does someone knows id Sharing is coming on SwiftData at WWDC 26? Anyway, can someone can point me an example a a configured coredata stack that share all its content with other icloud users (with sharing pane and accept invitation code). At this step, on the owner side, I see some data in the default zone of my private container but nothing is visible on the shared zone. Maybe I don't understand where and when I should check shared data in cloudkit console. Need Help also here. See below by configuration stack: // Core Data container public lazy var container: NSPersistentContainer = { switch delegate.usage() { case .preview : return previewContainer() case .local : return localContainer() case .cloudKit : return cloudKitContainer() } }() private func cloudKitContainer() -> NSPersistentContainer { let modelURL = delegate.modelURL() let modelName = modelURL.de
7
0
257
Mar ’26
Reply to NSFileManager getRelationship:ofDirectoryAtURL:toItemAtURL:error: returning NSURLRelationshipSame for Different Directories
The run loop itself doesn't actually turn at a predictable rate. Depending on how your app is architected and the overall app state, it's entirely possible for an app to go seconds or even minutes without the main thread ever running. Doesn't appear to be what's going on in this case. I made this dumb little test which can easily reproduce the issue (sorry can't get code to format well on these forums). +(MachoManURLTester*)sharedTester { static MachoManURLTester *sharedTester = nil; static dispatch_once_t token; dispatch_once(&token,^{ sharedTester = [[self alloc]init]; }); return sharedTester; } -(void)startURLTrashDance { NSAssert(NSThread.currentThread.isMainThread, @Main thread only.); NSFileManager *fm = [NSFileManager defaultManager]; NSURL *wrapperDir = [[NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES] URLByAppendingPathComponent:NSUUID.UUID.UUIDString isDirectory:YES]; if (![fm createDirectoryAtURL:wrapperDir withIntermediateDirectories:YES attributes:nil error:nil]) { NSLog(@Test f
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’26
Reply to Data Persistence not functioning upon refresh
The error message most likely happened because you changed the class name so the current SwiftData schema was different from what the existing store had used, as discussed here. I don't think that is the root cause of your issue. What catches my eyes is that you commented out the modelContext.save(). SwiftData supports auto-save, and yet, auto-save happens periodically. If you stop running your app before auto-save happens, the data will not be persisted. Other than that, I don't see any obvious issue in your code snippets. If you can share a runnable code that reproduces the issue, I may take another look. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Reply to Data Persistence not functioning upon refresh
Unrelated perhaps but why are you even using SwiftData for this, wouldn't it be better to use a CSV (or JSON) file for persisting your data? Maybe I am misreading the code but to me it looks like you only want to store a single instance of your model and then I believe SwiftData or any other database solution is overkill and that a simple file is more suitable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
I'm writing to express my frustration and disbelief that this critical bug is still present in production as of 2026. We just completed a major refactoring effort, migrating our application from iCloud-based static file storage to SwiftData with CloudKit sync. During this migration, we encountered this exact issue and was stunned to discover it was already documented in 2024. Here one of several specific scenarios: Logbook view structure: @Bindable var logbook: Logbook (where Logbook is a @Model class) The logbook.flights relationship array is not observed - changes to the array don't trigger view updates Attempted workaround using @Query var flights: [Flight] - still not observed This affects one of our primary user-facing views (flight logbook table) Why the suggested workaround doesn't work: The proposed solution of triggering refreshes on modelContext.didSave notifications is impractical for real-world applications: • Context saves can occur multiple times throughout the app's lifecycle
Feb ’26
Reply to How to Extract Accessibility Tree from WebKit Browser for both Web and Mobile
There is a WebDriver incubation effort ongoing with a standards proposal to be utilized in Web Platform Tests: https://github.com/WICG/aom/issues/203 https://github.com/web-platform-tests/wpt/pull/55784 Current test implementation PRs of the above are in Firefox/Gecko and Safari/WebKit, with interest indicated from the Chromium dev teams at Google/Chrome and Microsoft/Edge. There's a upcoming CSUN session about the above standards effort scheduled for 4:20 PM Pacific on Wednesday March 11. https://conference.csun.at/event/2026/session-schedule You can also review the WebKit Web Inspector, under Node > Accessibility to get parent/child relationships... https://webkit.org/blog/3302/aria-and-accessibility-inspector/ I do not recall if the WebKit Inspector JSON protocol used for those relationships is documented thoroughly anywhere, but the open source implementation pointer is: AccessibilityProperties in JavaScriptCore/inspector/protocol /DOM.json. https://github.com/WebKit/WebKit/blob/9602f
Feb ’26
What is the state of EventKit going forward?
I'm building an app that heavily relies on EKEventStore for calendar and reminder integration. The API is simple - and limited. Change notifications amount to something changed, you'd better refetch everything you care about. There's no way to know whether the calendar was updated while your app was closed or backgrounded. EKEvents and EKReminders don't trigger SwiftUI view updates, so you end up shunting them into your own observable state and keeping the two in sync. My app is fairly complex rendering-wise, and I lament being locked into treating EKEventStore as a first-class citizen of my view and data layer. It makes everything clunkier, essentially shuts the door on modern features like undo/redo, and makes integrating with other calendar providers that much harder. I'm exploring a custom SwiftData DataStore ↔ EKEventStore sync engine, but this is no easy task. There are still many unknowns I'd need to spike out before I can even attempt a proper implementation. Still, I'm curious - is this some
1
0
72
Feb ’26
Reply to Query with predicate in child view running too frequently.
When the query has a filter, SwiftData currently doesn't have a way to determine if the predicate changes every time AddTestStageView.init is called (because Predicate is not Equatable), and so assumes a re-fetch. To avoid the potential performance issue, you can probably consider re-designing your SwiftUI view hierarchy so the change of TextField doesn't trigger AddTestStageView.init, if that change is not relevant to the view. I’d also suggest that you file a feedback report – If you do so, please share your report ID here. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Reply to Access Relationship value from deleted model tombstone in SwiftData.
Just to confirm that @Attribute(.preserveValueOnDeletion) doesn't preserve relationships. It only works for attributes. Given that, I don't see anything in the SwiftData history that can help restore a relationship between two SwiftData objects after they are deleted. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’26
Reply to Driver Activation failure error code 9. Maybe Entitlements? Please help
First, I wanted to apologize for not replying for a full month, as well as thank you very much for your reply. I was pulled away from this project for a couple weeks, and when I got back I was still spinning my wheels getting the driver installed. Not a problem at all. It was 67 characters and, apparently the maximum is 63. Seems like an arbitrarily short max in this day and age, and you'd think both XCode and the Developer Portal would catch that, but that's what it was. Sigh... I'm sorry I didn't think of that, as I'm aware of that limitation and actually posted about it here. FYI, you should also be aware of the version number limitation described here, which is another arbitrary restriction the kernel enforces. So, on to my current problem. The driver installs... but doesn't load. Probably because it's not matching. So I'm going to give more detailed information in the hope you can help me with this. If you haven't seen it already, I have a post here that does an extended run down of the matching and load
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Mar ’26
Reply to CloudKit Sync Stalls During Initial Large Data Hydration on New Device (SwiftData Local-First Architecture)
For a large dataset, the initial synchronization with CloudKit, which can happen in several cases, including on-boarding a new device, can indeed be slow, or even failed. A similar issue was discussed in this thread as well. Depending on your concrete use case, you might address the issue in the following way: Have your app functional before the dataset is fully synchronized. Synchronize the data in batches in the background, until the whole data set is done. As an example, an email app that is just installed on a new device allows users to compose a new email, while synchronizing existing emails in the background. When using the CloudKit framework, you control what kind and amount of data to be synchronized with CloudKit, and hence can implement the strategy, though the implementation can be quite involved. Now that you are using SwiftData + CloudKit integration, NSPersistentCloudKitContainer takes care the synchronization process. I don't really see anything to work around or mitigate the issue in
Replies
Boosts
Views
Activity
Mar ’26
Access Relationship value from deleted model tombstone in SwiftData.
I’m developing an app using SwiftData. In my app, I have two models: User and Address. A user can have multiple addresses. I’m trying to use SwiftData History tracking to implement some logic when addresses are deleted. Specifically, I need to determine which user the address belonged to. From the documentation, I understand that you can preserve attributes from deleted models in a tombstone object using @Attribute(.preserveValueOnDeletion). However, this isn’t working when I try to apply this to a relationship value. Below is a simplified example of my attempts so far. I suspect that simply adding @Attribute(.preserveValueOnDeletion) to a relationship isn’t feasible. If that’s indeed the case, what would be the recommended approach to identify the user associated with an address after it has been deleted? Thank you. @Model class User { var name: String @Relationship(deleteRule: .cascade, inverse: Address.user) var addresses: [Address] = [] init(name: String) { sel
Replies
1
Boosts
0
Views
91
Activity
Mar ’26
SwiftData Unidirectional Relationships
Hi everyone I would like to achieve having unidirectional relationships in my SwiftData project (which I believe is possible: https://developer.apple.com/documentation/updates/swiftdata?changes=_9) but I'm afraid I'm struggling to overcome the errors I'm experiencing. For example, I have the following models: @Model final class Quota { @Attribute(.unique) var id: UUID var allowance: Int @Relationship(inverse: nil) var fish: Fish init(id: UUID = UUID(), fish: Fish, allowance: Int) { self.id = id self.fish = fish self.allowance = allowance } } @Model final class Fish { @Attribute(.unique) var id: Int var name: String init(id: Int, name: String) { self.id = id, self.name = name } } However, when I attempt to save a quota as so: let quota: Quota = .init(fish: Fish(id: 2, name: Salmon), allowance: 50) modelContext?.insert(quota) try save() I keep getting the following error: SwiftData.DefaultStore save failed with error: Error Domain=NSCocoaErrorDomain Code=1570 %{PROPERTY}@ is
Replies
1
Boosts
0
Views
185
Activity
Mar ’26
CloudKit Sync Stalls During Initial Large Data Hydration on New Device (SwiftData Local-First Architecture)
Hi everyone, I’m facing an issue with CloudKit sync getting stuck during initial device migration in my SwiftData-based app. The app follows a local-first architecture using SwiftData + CloudKit sync, and works correctly for: ✔ Incremental sync ✔ Bi-directional updates ✔ Small datasets However, when onboarding a new device with large historical data, sync becomes extremely slow or appears stuck. Even after two hours data is not fully synced. ~6900 Transactions 🚨 Problem When installing the app on a new iPhone and enabling iCloud sync: • Initial hydration starts • A small amount of data syncs • Then sync stalls indefinitely Observed behaviour: • iPhone → Mac sync works (new changes sync back) • Mac → iPhone large historical migration gets stuck • Reinstalling app / clearing container does not resolve issue • Sync never completes full migration This gives the impression that: CloudKit is trickling data but not progressing after a certain threshold. The architecture is: • SwiftData lo
Replies
1
Boosts
0
Views
156
Activity
Mar ’26
Sharing all container content
I've understood that SwiftData is not abled to share the whole content of a cloudkit database. So I'm trying to rewrite everything. Does someone knows id Sharing is coming on SwiftData at WWDC 26? Anyway, can someone can point me an example a a configured coredata stack that share all its content with other icloud users (with sharing pane and accept invitation code). At this step, on the owner side, I see some data in the default zone of my private container but nothing is visible on the shared zone. Maybe I don't understand where and when I should check shared data in cloudkit console. Need Help also here. See below by configuration stack: // Core Data container public lazy var container: NSPersistentContainer = { switch delegate.usage() { case .preview : return previewContainer() case .local : return localContainer() case .cloudKit : return cloudKitContainer() } }() private func cloudKitContainer() -> NSPersistentContainer { let modelURL = delegate.modelURL() let modelName = modelURL.de
Replies
7
Boosts
0
Views
257
Activity
Mar ’26
Reply to SwiftData with shared and private containers
Same problem for me !!!! use SwiftData, build great apps and POC… Then when you'll need sharing rewrite everything with coredata (that you may not mastered). As an independent developer it is really a pain. At least If I was sure that the sharing feature is schedule!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’26
Reply to NSFileManager getRelationship:ofDirectoryAtURL:toItemAtURL:error: returning NSURLRelationshipSame for Different Directories
The run loop itself doesn't actually turn at a predictable rate. Depending on how your app is architected and the overall app state, it's entirely possible for an app to go seconds or even minutes without the main thread ever running. Doesn't appear to be what's going on in this case. I made this dumb little test which can easily reproduce the issue (sorry can't get code to format well on these forums). +(MachoManURLTester*)sharedTester { static MachoManURLTester *sharedTester = nil; static dispatch_once_t token; dispatch_once(&token,^{ sharedTester = [[self alloc]init]; }); return sharedTester; } -(void)startURLTrashDance { NSAssert(NSThread.currentThread.isMainThread, @Main thread only.); NSFileManager *fm = [NSFileManager defaultManager]; NSURL *wrapperDir = [[NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES] URLByAppendingPathComponent:NSUUID.UUID.UUIDString isDirectory:YES]; if (![fm createDirectoryAtURL:wrapperDir withIntermediateDirectories:YES attributes:nil error:nil]) { NSLog(@Test f
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Data Persistence not functioning upon refresh
The error message most likely happened because you changed the class name so the current SwiftData schema was different from what the existing store had used, as discussed here. I don't think that is the root cause of your issue. What catches my eyes is that you commented out the modelContext.save(). SwiftData supports auto-save, and yet, auto-save happens periodically. If you stop running your app before auto-save happens, the data will not be persisted. Other than that, I don't see any obvious issue in your code snippets. If you can share a runnable code that reproduces the issue, I may take another look. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Data Persistence not functioning upon refresh
Unrelated perhaps but why are you even using SwiftData for this, wouldn't it be better to use a CSV (or JSON) file for persisting your data? Maybe I am misreading the code but to me it looks like you only want to store a single instance of your model and then I believe SwiftData or any other database solution is overkill and that a simple file is more suitable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
I'm writing to express my frustration and disbelief that this critical bug is still present in production as of 2026. We just completed a major refactoring effort, migrating our application from iCloud-based static file storage to SwiftData with CloudKit sync. During this migration, we encountered this exact issue and was stunned to discover it was already documented in 2024. Here one of several specific scenarios: Logbook view structure: @Bindable var logbook: Logbook (where Logbook is a @Model class) The logbook.flights relationship array is not observed - changes to the array don't trigger view updates Attempted workaround using @Query var flights: [Flight] - still not observed This affects one of our primary user-facing views (flight logbook table) Why the suggested workaround doesn't work: The proposed solution of triggering refreshes on modelContext.didSave notifications is impractical for real-world applications: • Context saves can occur multiple times throughout the app's lifecycle
Replies
Boosts
Views
Activity
Feb ’26
Reply to How to Extract Accessibility Tree from WebKit Browser for both Web and Mobile
There is a WebDriver incubation effort ongoing with a standards proposal to be utilized in Web Platform Tests: https://github.com/WICG/aom/issues/203 https://github.com/web-platform-tests/wpt/pull/55784 Current test implementation PRs of the above are in Firefox/Gecko and Safari/WebKit, with interest indicated from the Chromium dev teams at Google/Chrome and Microsoft/Edge. There's a upcoming CSUN session about the above standards effort scheduled for 4:20 PM Pacific on Wednesday March 11. https://conference.csun.at/event/2026/session-schedule You can also review the WebKit Web Inspector, under Node > Accessibility to get parent/child relationships... https://webkit.org/blog/3302/aria-and-accessibility-inspector/ I do not recall if the WebKit Inspector JSON protocol used for those relationships is documented thoroughly anywhere, but the open source implementation pointer is: AccessibilityProperties in JavaScriptCore/inspector/protocol /DOM.json. https://github.com/WebKit/WebKit/blob/9602f
Replies
Boosts
Views
Activity
Feb ’26
What is the state of EventKit going forward?
I'm building an app that heavily relies on EKEventStore for calendar and reminder integration. The API is simple - and limited. Change notifications amount to something changed, you'd better refetch everything you care about. There's no way to know whether the calendar was updated while your app was closed or backgrounded. EKEvents and EKReminders don't trigger SwiftUI view updates, so you end up shunting them into your own observable state and keeping the two in sync. My app is fairly complex rendering-wise, and I lament being locked into treating EKEventStore as a first-class citizen of my view and data layer. It makes everything clunkier, essentially shuts the door on modern features like undo/redo, and makes integrating with other calendar providers that much harder. I'm exploring a custom SwiftData DataStore ↔ EKEventStore sync engine, but this is no easy task. There are still many unknowns I'd need to spike out before I can even attempt a proper implementation. Still, I'm curious - is this some
Replies
1
Boosts
0
Views
72
Activity
Feb ’26
Reply to Query with predicate in child view running too frequently.
When the query has a filter, SwiftData currently doesn't have a way to determine if the predicate changes every time AddTestStageView.init is called (because Predicate is not Equatable), and so assumes a re-fetch. To avoid the potential performance issue, you can probably consider re-designing your SwiftUI view hierarchy so the change of TextField doesn't trigger AddTestStageView.init, if that change is not relevant to the view. I’d also suggest that you file a feedback report – If you do so, please share your report ID here. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26