Search results for

“SwiftData inheritance relationship”

4,986 results found

Post

Replies

Boosts

Views

Activity

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
Importing Data into SwiftData in the Background Using ModelActor and @Query
I have an app with fairly typical requirements - I need to insert some data (in my case from the network but could be anything) and I want to do it in the background to keep the UI responsive. I'm using SwiftData. I've created a ModelActor that does the importing and using the debugger I can confirm that the data is indeed being inserted. On the UI side, I'm using @Query and a SwiftUI List to display the data but what I am seeing is that @Query is not updating as the data is being inserted. I have to quit and re-launch the app in order for the data to appear, almost like the context running the UI isn't communicating with the context in the ModelActor. I've included a barebones sample project. To reproduce the issue, tap the 'Background Insert' button. You'll see logs that show items being inserted but the UI is not showing any data. I've tested on the just released iOS 18b3 seed (22A5307f). The sample project is here: https://hanchor.s3.amazonaws.com/misc/SwiftDataBackgroundV2.zip
24
0
6.3k
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
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 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
Query with predicate in child view running too frequently.
I'm trying to determine if this is expected swiftui behavior or an issue with SwiftUI/Data which needs a feedback request... When a child view has a Query containing a filter predicate, the query is run with each and every edit of the parent view, even when the edit has no impact on the child view (e.g. bindings not changing). In the example below, ContentView has the TextField name, and while data is being entered in it, causes the Query in AddTestStageView to be run with each character typed, e.g. 30 characters result in 30 query executions. (Need -com.apple.CoreData.SQLDebug 1 launch argument to see SQL output). Removing the filter predicate from the query and filtering in ForEach prevents the issue. In my actual use case, the query has a relatively small result set (<100 rows), but I can see this as a performance issue with the larger result sets. xcode/ios: 26.2 Repro example code: import SwiftUI import SwiftData // Repro to Query filter issue in child view running multiple time unexpectedly
1
0
84
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
Thread topology data: no API path for parent-child relationships
I'm building a HomeKit app that discovers Thread devices and visualizes the mesh topology. I can detect device roles (Router vs End Device via characteristic 0x0703) and identify Border Routers (via _meshcop._udp), but I cannot determine which Router is the parent of a given End Device. Any Thread device can act as a Router (a Nanoleaf bulb, an Eve plug, not just HomePods), and End Devices attach to these Routers as children. That parent-child relationship is what I'm trying to map, but there's no RLOC16, neighbor table, or parent identifier exposed through any available API. I've tested every path I can find. Here's what I've tried on a network with 44 Thread devices and 6 Border Routers: What works (partially) HAP Thread Management Service (0x0701) gives me the device role from characteristic 0x0703, the OpenThread version from 0x0706, and node capabilities from 0x0702. That's the complete set of characteristics on that service. None of them contain RLOC16, parent Router, or neighbor data. This ser
1
0
155
Feb ’26
Reply to Cannot get WiFi SSID inside launchctl agent
On recent versions of macOS a program needs the Location privilege (from System Settings > Privacy & Security) to access SSID information. It should be feasible for a launchd agent to get that — unlike, say, a launchd daemon — but it’s not without its challenges. My usual advice here is: Install the from a container app using SMAppService. This ensures that the system understands the relationship between the app and the agent. Request the Location privilege in the container app. In the agent, confirm that you have the Location privilege before attempting to do anything with Core WLAN. There’s a new-fangled way to do this but I tend to rely on the old ways. I’ve run through this process for other privileges and it works a treat. However, the Location privilege is kinda weird — it’s not managed by the standard TCC infrastructure — so I’m not 100% sure this will work in that case. But give it a whirl and lemme know how you get along. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Sup
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’26
SwiftData + CloudKit: BGSystemTaskScheduler Code=8
Hi everyone, On macOS 26.4 beta (with Xcode 26.4 beta), I’m seeing the following console messages in a brand new SwiftData + CloudKit template project (no custom logic added, fresh CloudKit container): updateTaskRequest called for a pre-running task com.apple.coredata.cloudkit.activity.export.F9EE783D-7521-4EC2-B42C-9FD1F29BA5C4 updateTaskRequest called for an already running/updated task com.apple.coredata.cloudkit.activity.export.F9EE783D-7521-4EC2-B42C-9FD1F29BA5C4 Error updating background task request: Error Domain=BGSystemTaskSchedulerErrorDomain Code=8 (null) These messages appear: When CloudKit is enabled Occasionally on app launch Often when bringing the app back to the foreground (Cmd-Tab away and back) Even with zero additional SwiftData logic They do not appear when CloudKit is disabled. This behavior is reproducible on a completely new project with a fresh CloudKit container. Questions: What exactly do these messages indicate? Is BGSystemTaskScheduler Code=8 expected in this con
2
0
196
Feb ’26
Recent changes to the App Store Connect API has broken the ability to set the IN_APP_PASS_PROVISIONING capability type
We have been using this API call to set the In-App Provisioning capability for 2+ years and it just recently started returning errors. To set the In-App Provisioning capability we had been using the App Store Connect API directly: curl https://api.appstoreconnect.apple.com/v1/bundleIdCapabilities -X POST --header Authorization: Bearer #{appleApiToken} --header Content-Type: application/json -d '{data: {type: bundleIdCapabilities, attributes: {capabilityType: IN_APP_PASS_PROVISIONING}, relationships: {bundleId: {data: {id: #{appStoreBundleIdentifier}, type: bundleIds}}}}}' The IN_APP_PASS_PROVISIONING capability type is shown, by getting the bundle ID capabilities, when In-App Provisioning is set on a bundle ID: curl https://api.appstoreconnect.apple.com/v1/bundleIds/#{appStoreBundleIdentifier}/bundleIdCapabilities --header Authorization: Bearer #{appleApiToken} After manually setting the In-App Provisioning capability via the Apple Developer portal you will see the new capabilityType: { type : bundl
3
0
784
Feb ’26
macOS to macOS SwiftData iCloud Sync Problems
I am a novice developer, so please be kind. 😬 I am developing a simple macOS app backed with SwiftData and trying to set up iCloud sync so data syncs between two Macs running the app. I have added the iCloud capability, checked the CloudKit box, and selected an iCloud Container. Per suggestion of Paul Hudson, my model properties have either default values or are marked as optional, and the only relationship in my model is marked as optional. @Model final class Project { // Stable identifier used for restoring selected project across launches. var uuid: UUID? var name: String = var active: Bool = true var created: Date = Foundation.Date(timeIntervalSince1970: 0) var modified: Date = Foundation.Date(timeIntervalSince1970: 0) // CloudKit requires to-many relationships to be optional in this schema. @Relationship var timeEntries: [TimeEntry]? init(name: String, active: Bool = true, uuid: UUID? = UUID()) { self.uuid = uuid self.name = name self.active = active self.created = .
4
0
197
Feb ’26
Reply to macOS to macOS SwiftData iCloud Sync Problems
When using SwiftData + CloudKit integration, which uses NSPersistentCloudKitContainer under the hood, the synchronization typically doesn't happen immediately. To better understand the synchronization, consider going through the following technotes: TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles In your case, the first three bullets are pretty much as-designed. The last one, no edits sync between either Mac, if lasting for ever, which means the synchronization is broken, will be an issue. In that case, you can figure out what happens by capturing and analyzing a sysdiagnose, as described in TN3163. Best, —— Ziqiao Chen  Worldwide Developer Relations.
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
Importing Data into SwiftData in the Background Using ModelActor and @Query
I have an app with fairly typical requirements - I need to insert some data (in my case from the network but could be anything) and I want to do it in the background to keep the UI responsive. I'm using SwiftData. I've created a ModelActor that does the importing and using the debugger I can confirm that the data is indeed being inserted. On the UI side, I'm using @Query and a SwiftUI List to display the data but what I am seeing is that @Query is not updating as the data is being inserted. I have to quit and re-launch the app in order for the data to appear, almost like the context running the UI isn't communicating with the context in the ModelActor. I've included a barebones sample project. To reproduce the issue, tap the 'Background Insert' button. You'll see logs that show items being inserted but the UI is not showing any data. I've tested on the just released iOS 18b3 seed (22A5307f). The sample project is here: https://hanchor.s3.amazonaws.com/misc/SwiftDataBackgroundV2.zip
Replies
24
Boosts
0
Views
6.3k
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
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 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
Query with predicate in child view running too frequently.
I'm trying to determine if this is expected swiftui behavior or an issue with SwiftUI/Data which needs a feedback request... When a child view has a Query containing a filter predicate, the query is run with each and every edit of the parent view, even when the edit has no impact on the child view (e.g. bindings not changing). In the example below, ContentView has the TextField name, and while data is being entered in it, causes the Query in AddTestStageView to be run with each character typed, e.g. 30 characters result in 30 query executions. (Need -com.apple.CoreData.SQLDebug 1 launch argument to see SQL output). Removing the filter predicate from the query and filtering in ForEach prevents the issue. In my actual use case, the query has a relatively small result set (<100 rows), but I can see this as a performance issue with the larger result sets. xcode/ios: 26.2 Repro example code: import SwiftUI import SwiftData // Repro to Query filter issue in child view running multiple time unexpectedly
Replies
1
Boosts
0
Views
84
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
Thread topology data: no API path for parent-child relationships
I'm building a HomeKit app that discovers Thread devices and visualizes the mesh topology. I can detect device roles (Router vs End Device via characteristic 0x0703) and identify Border Routers (via _meshcop._udp), but I cannot determine which Router is the parent of a given End Device. Any Thread device can act as a Router (a Nanoleaf bulb, an Eve plug, not just HomePods), and End Devices attach to these Routers as children. That parent-child relationship is what I'm trying to map, but there's no RLOC16, neighbor table, or parent identifier exposed through any available API. I've tested every path I can find. Here's what I've tried on a network with 44 Thread devices and 6 Border Routers: What works (partially) HAP Thread Management Service (0x0701) gives me the device role from characteristic 0x0703, the OpenThread version from 0x0706, and node capabilities from 0x0702. That's the complete set of characteristics on that service. None of them contain RLOC16, parent Router, or neighbor data. This ser
Replies
1
Boosts
0
Views
155
Activity
Feb ’26
Reply to Cannot get WiFi SSID inside launchctl agent
On recent versions of macOS a program needs the Location privilege (from System Settings > Privacy & Security) to access SSID information. It should be feasible for a launchd agent to get that — unlike, say, a launchd daemon — but it’s not without its challenges. My usual advice here is: Install the from a container app using SMAppService. This ensures that the system understands the relationship between the app and the agent. Request the Location privilege in the container app. In the agent, confirm that you have the Location privilege before attempting to do anything with Core WLAN. There’s a new-fangled way to do this but I tend to rely on the old ways. I’ve run through this process for other privileges and it works a treat. However, the Location privilege is kinda weird — it’s not managed by the standard TCC infrastructure — so I’m not 100% sure this will work in that case. But give it a whirl and lemme know how you get along. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Sup
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to App Review Guideline 4.3(a) - Design - Spam for our own App
Perhaps, it's obvious. But what's obvious to you is not really obvious to the rest of the world. I would explain in detail the relationship between we or our or our own account and all other parties including Osiel Lima, developer, the previous account.
Replies
Boosts
Views
Activity
Feb ’26
SwiftData + CloudKit: BGSystemTaskScheduler Code=8
Hi everyone, On macOS 26.4 beta (with Xcode 26.4 beta), I’m seeing the following console messages in a brand new SwiftData + CloudKit template project (no custom logic added, fresh CloudKit container): updateTaskRequest called for a pre-running task com.apple.coredata.cloudkit.activity.export.F9EE783D-7521-4EC2-B42C-9FD1F29BA5C4 updateTaskRequest called for an already running/updated task com.apple.coredata.cloudkit.activity.export.F9EE783D-7521-4EC2-B42C-9FD1F29BA5C4 Error updating background task request: Error Domain=BGSystemTaskSchedulerErrorDomain Code=8 (null) These messages appear: When CloudKit is enabled Occasionally on app launch Often when bringing the app back to the foreground (Cmd-Tab away and back) Even with zero additional SwiftData logic They do not appear when CloudKit is disabled. This behavior is reproducible on a completely new project with a fresh CloudKit container. Questions: What exactly do these messages indicate? Is BGSystemTaskScheduler Code=8 expected in this con
Replies
2
Boosts
0
Views
196
Activity
Feb ’26
Recent changes to the App Store Connect API has broken the ability to set the IN_APP_PASS_PROVISIONING capability type
We have been using this API call to set the In-App Provisioning capability for 2+ years and it just recently started returning errors. To set the In-App Provisioning capability we had been using the App Store Connect API directly: curl https://api.appstoreconnect.apple.com/v1/bundleIdCapabilities -X POST --header Authorization: Bearer #{appleApiToken} --header Content-Type: application/json -d '{data: {type: bundleIdCapabilities, attributes: {capabilityType: IN_APP_PASS_PROVISIONING}, relationships: {bundleId: {data: {id: #{appStoreBundleIdentifier}, type: bundleIds}}}}}' The IN_APP_PASS_PROVISIONING capability type is shown, by getting the bundle ID capabilities, when In-App Provisioning is set on a bundle ID: curl https://api.appstoreconnect.apple.com/v1/bundleIds/#{appStoreBundleIdentifier}/bundleIdCapabilities --header Authorization: Bearer #{appleApiToken} After manually setting the In-App Provisioning capability via the Apple Developer portal you will see the new capabilityType: { type : bundl
Replies
3
Boosts
0
Views
784
Activity
Feb ’26
macOS to macOS SwiftData iCloud Sync Problems
I am a novice developer, so please be kind. 😬 I am developing a simple macOS app backed with SwiftData and trying to set up iCloud sync so data syncs between two Macs running the app. I have added the iCloud capability, checked the CloudKit box, and selected an iCloud Container. Per suggestion of Paul Hudson, my model properties have either default values or are marked as optional, and the only relationship in my model is marked as optional. @Model final class Project { // Stable identifier used for restoring selected project across launches. var uuid: UUID? var name: String = var active: Bool = true var created: Date = Foundation.Date(timeIntervalSince1970: 0) var modified: Date = Foundation.Date(timeIntervalSince1970: 0) // CloudKit requires to-many relationships to be optional in this schema. @Relationship var timeEntries: [TimeEntry]? init(name: String, active: Bool = true, uuid: UUID? = UUID()) { self.uuid = uuid self.name = name self.active = active self.created = .
Replies
4
Boosts
0
Views
197
Activity
Feb ’26
Reply to macOS to macOS SwiftData iCloud Sync Problems
When using SwiftData + CloudKit integration, which uses NSPersistentCloudKitContainer under the hood, the synchronization typically doesn't happen immediately. To better understand the synchronization, consider going through the following technotes: TN3164: Debugging the synchronization of NSPersistentCloudKitContainer TN3163: Understanding the synchronization of NSPersistentCloudKitContainer TN3162: Understanding CloudKit throttles In your case, the first three bullets are pretty much as-designed. The last one, no edits sync between either Mac, if lasting for ever, which means the synchronization is broken, will be an issue. In that case, you can figure out what happens by capturing and analyzing a sysdiagnose, as described in TN3163. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Feb ’26