Post

Replies

Boosts

Views

Activity

Reply to Enabling undo with multi-model schema
Trying to figure out if this is possible for a sharedModelContainer. When creating a new empty multiplatform app with SwiftData, this code is automatically generated in the App.swift: import SwiftUI import SwiftData @main struct SwiftDataTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Item.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() } .modelContainer(sharedModelContainer) } } Is there a way to set isUndoEnabled in this scenario? Doesn't look like ModelContainer(for: Schema...) supports it?
Dec ’23
Reply to SwiftData Update Item View from Background Thread
Quick question, are you on iOS 18? Did it work in iOS 17? I'm trying to figure out a similar issue that worked in iOS 17, but doesn't work in iOS 18 Beta 1 and Beta 2 (just updated today). In a nutshell I have a parent and child view as part of a NavigationSplitView. A parent view has a @Query for items, the item is passed to the child view, like in your case. In the child there is a method that performs an async task, which updates the item in the background using @ModelActor This update was immediately refrelcted in the child view on iOS 17 but is not reflected in iOS 18. Only if I navigate to parent view and then re-open child I can see the changes.
Jun ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
Yes, it seems something was fixed (using Beta 6 and Xcode 16 b5). In my case I could get rid of the previous workaround with Notification Center and I can see the changes reflecting in the views. However there are definitely new problems with saving models - in some cases it appears a model's @Relationship is not saved. Will try to recreate this in a test project. In the meantime, @DTS Engineer - any comments on the new changes? PS. it is really quite frustrating that there is no mention of SwiftData issues in any of the Release Notes although changes are evidently being made
Aug ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
Thanks for your reply, @DTS Engineer, I'm not sure the issue is related to the timing as in my case the try modelContext.save() is called after each operation. Also the example in the other post seems to be dealing with synchronous operations, rather than async via ModelActor. Still trying to replicate the exact steps. All I can see that a @Relationship is removed somehow beween two models some time after saving via ModelActor (can see that in CloudKit console), but it works correctly in iOS 17.5
Aug ’24
Reply to SwiftData iCloud sync breaks after disabling and re-enabling iCloud
Thanks for the suggestion, @DTS Engineer, I saved the sysdiagnose and filtered it to errors. This is using a basic example project from Xcode. I'm running it on iPhone and Mac and when saving items from iPhone I can see them appear in CloudKit database, but they don't get synced to the Mac. And these are 5 errors that are looping when the Mac is trying to sync (I assume): 1 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1242): <NSCloudKitMirroringDelegate: 0x60000377c000>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x13dc04080> (URL: file:///Users/admin/Library/Containers/ca.maybelater.SequoiaSync2/Data/Library/Application%20Support/default.store) <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 2 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2312): <NSCloudKitMirroringDelegate: 0x60000377c000> - Attempting recovery from error: <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 3 Error retrieving daemon to get network transfer endpoint: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction.} 4 Error getting network transfer endpoint: <CKError 0x600000600990: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 5 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:](612): <NSCloudKitMirroringDelegate: 0x60000377c000> - resetting internal state after error: <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> And then it goes back to 1 and repeats. Does it look like a specific device issue?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to SwiftData iCloud sync breaks after disabling and re-enabling iCloud
After following a combination of these steps I got the sync back, although I ended up creating a new CloudKit container too. What I did: removed the apps from all devices made sure the store was removed on Mac logged out of iCloud on Mac, logged back in and rebooted (I don't think I did reboot before) unchecked and rechecked 'Automatically manage signing' in Signing & Capabilities (also didn't do that before) added a new CloudKit container and verified that it's assigned to the correct App ID. I previously tried adding a new container, but without these other steps it didn't work. So looks like it was a local issue after all. I moved the project from one machine to another recently and probably that broke the sync somehow. The app was run from Xcode. Thanks for your help, @DTS Engineer!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to Convert Chrome/Firefox Extension to Safari
I found that Unable to parse manifest.json at file is thrown if manifest_version is not 2 Latest Chrome extensions use manifest version 3 and looks like Xcode can't handle it.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Embedding a NavigationStack within the detail view of a NavigationSplitView
Experiencing the same on iOS 17.2 beta 3, the delay with which .toolbar appears is very noticeable
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’23
Reply to Embedding a NavigationStack within the detail view of a NavigationSplitView
Here is an example, the toolbar items appear with delay in detail view.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’23
Reply to Xcode 15.1 & iOS 17.2: SwiftData ModelContext Delete: It's only possible to delete the data after it has been inserted for about 30 seconds
In your addSamples try explicitly saving context after inserting models: try? modelContext.save(), this should allow deleting immediately.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to Enabling undo with multi-model schema
Trying to figure out if this is possible for a sharedModelContainer. When creating a new empty multiplatform app with SwiftData, this code is automatically generated in the App.swift: import SwiftUI import SwiftData @main struct SwiftDataTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Item.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() } .modelContainer(sharedModelContainer) } } Is there a way to set isUndoEnabled in this scenario? Doesn't look like ModelContainer(for: Schema...) supports it?
Replies
Boosts
Views
Activity
Dec ’23
Reply to SwiftData Update Item View from Background Thread
Quick question, are you on iOS 18? Did it work in iOS 17? I'm trying to figure out a similar issue that worked in iOS 17, but doesn't work in iOS 18 Beta 1 and Beta 2 (just updated today). In a nutshell I have a parent and child view as part of a NavigationSplitView. A parent view has a @Query for items, the item is passed to the child view, like in your case. In the child there is a method that performs an async task, which updates the item in the background using @ModelActor This update was immediately refrelcted in the child view on iOS 17 but is not reflected in iOS 18. Only if I navigate to parent view and then re-open child I can see the changes.
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftData fatal error "Never access a full future backing data"
Also getting this quite often when deleting a model
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftData Update Item View from Background Thread
Beta 4, still broken
Replies
Boosts
Views
Activity
Jul ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
This workaround worked for me, thanks @DTS Engineer 👍
Replies
Boosts
Views
Activity
Jul ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
Yes, it seems something was fixed (using Beta 6 and Xcode 16 b5). In my case I could get rid of the previous workaround with Notification Center and I can see the changes reflecting in the views. However there are definitely new problems with saving models - in some cases it appears a model's @Relationship is not saved. Will try to recreate this in a test project. In the meantime, @DTS Engineer - any comments on the new changes? PS. it is really quite frustrating that there is no mention of SwiftData issues in any of the Release Notes although changes are evidently being made
Replies
Boosts
Views
Activity
Aug ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
Thanks for your reply, @DTS Engineer, I'm not sure the issue is related to the timing as in my case the try modelContext.save() is called after each operation. Also the example in the other post seems to be dealing with synchronous operations, rather than async via ModelActor. Still trying to replicate the exact steps. All I can see that a @Relationship is removed somehow beween two models some time after saving via ModelActor (can see that in CloudKit console), but it works correctly in iOS 17.5
Replies
Boosts
Views
Activity
Aug ’24
Reply to SwiftData error when trying to save array in Model
Sorry, was away for a week and now it seems to be working correctly in Beta 8.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to SwiftData iCloud sync breaks after disabling and re-enabling iCloud
Update: Looks like the bug exists even without disabling and enabling iCloud. It can be reproduced by starting a new project from Xcode templates: New Project > Multiplatform app with SwiftData and CloudKit Looks like the sync is broken on macOS 15.0.1 (although works on iOS 18 and 18.1 and on macOS 14.7)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to SwiftData iCloud sync breaks after disabling and re-enabling iCloud
Thanks for the suggestion, @DTS Engineer, I saved the sysdiagnose and filtered it to errors. This is using a basic example project from Xcode. I'm running it on iPhone and Mac and when saving items from iPhone I can see them appear in CloudKit database, but they don't get synced to the Mac. And these are 5 errors that are looping when the Mac is trying to sync (I assume): 1 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1242): <NSCloudKitMirroringDelegate: 0x60000377c000>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x13dc04080> (URL: file:///Users/admin/Library/Containers/ca.maybelater.SequoiaSync2/Data/Library/Application%20Support/default.store) <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 2 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromError:](2312): <NSCloudKitMirroringDelegate: 0x60000377c000> - Attempting recovery from error: <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 3 Error retrieving daemon to get network transfer endpoint: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction.} 4 Error getting network transfer endpoint: <CKError 0x600000600990: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> 5 error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:](612): <NSCloudKitMirroringDelegate: 0x60000377c000> - resetting internal state after error: <CKError 0x60000064adf0: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds> And then it goes back to 1 and repeats. Does it look like a specific device issue?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to SwiftData iCloud sync breaks after disabling and re-enabling iCloud
After following a combination of these steps I got the sync back, although I ended up creating a new CloudKit container too. What I did: removed the apps from all devices made sure the store was removed on Mac logged out of iCloud on Mac, logged back in and rebooted (I don't think I did reboot before) unchecked and rechecked 'Automatically manage signing' in Signing & Capabilities (also didn't do that before) added a new CloudKit container and verified that it's assigned to the correct App ID. I previously tried adding a new container, but without these other steps it didn't work. So looks like it was a local issue after all. I moved the project from one machine to another recently and probably that broke the sync somehow. The app was run from Xcode. Thanks for your help, @DTS Engineer!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24