Search results for

“SwiftData inheritance relationship”

4,986 results found

Post

Replies

Boosts

Views

Activity

Reply to App stuck in status Waiting for Review since Feb 9
Alright, so I'm gonna send an email out to Eddy, Matt and Susan. If anyone wants to be copied, paste your email address here. This is just beyond belief. It is unfortunate we have to let Apple leadership know this service is broken and most probably call out people (sadly). This sort of delay is severely severed my relationship with customers and users. I plan to send the email out over the week-end
3w
Reply to Significantly Delayed App Review
Alright, so I'm gonna send an email out to Eddy, Matt and Susan. If anyone wants to be copied, paste your email address here. This is just beyond belief. It is unfortunate we have to let Apple leadership know this service is broken and most probably call out people (sadly). This sort of delay is severely severed my relationship with customers and users. I plan to send the email out over the week-end.
3w
Reply to NSFileManager getRelationship:ofDirectoryAtURL:toItemAtURL:error: returning NSURLRelationshipSame for Different Directories
Very interesting info! I can understand that thinking, but it's not the system’s perspective. The system’s view here is that the file reference is considered more authoritative than the path. I actually don't have a strong opinion about file reference urls vs. file path urls but from my perspective in the sample it is clear after the second call to createDirectoryAtURL:..., when that method returns, the fileReferenceURL left lingering in that untitleFour instance is pointing to to the wrong folder based on the fact that I fed that URL directly into a method to create a folder, the operation succeeded, yet there is still a chance to accidentally access a completely different folder through that very same instance going through the cached fileReferenceURL. MacOS itself is heavily still reliant on path, but fileReferenceURLs are the closest construct we have to an API that doesn't fall into this trap. Yea. You can't even create a file without a path so there is that. File reference urls are great at certain thin
Topic: App & System Services SubTopic: Core OS Tags:
4w
Reply to FileManager.replaceItemAt(_:withItemAt:) fails sporadically on ubiquitous items
Out of curiosity, I just tested this, and I still see the bug. To see it yourself, just use the code from my first post but change the savingURL accessor to use a security-scoped bookmark, as follows: To be honest, that was basically a blind (well, slightly educated...) guess. To be honest, the whole combination of factors is fairly odd (timing is random, failure self-corrects, etc.). One thing to pass along— I just did a bit of testing with retrying the copy, and clearing the error seems to be tied to TIME, not retry count. If you decide to go the retry route, you may want to delay the save for a second or so instead of just retrying over and over. I’m actually doing (b), since this is very fast on copy-on-write volumes such as APFS even for large files. (Copy-to-temp file is almost instant.) I think very fast actually understates how significant the performance difference is. As an industry, I'm not sure we've really processed how constant-time copying should change file management. For slower volumes, much
Topic: App & System Services SubTopic: Core OS Tags:
4w
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
4w
Reply to Sharing all container content
I want to share all the content of a CloudKit database at once between different iCloud accounts. For example, to manage products storage between users. Once the database has been shared or an invitation has been accepted, any additions/modifications/deletions to storage or products must be shared between all users without additional sharing. To be short after the first sharing, everything must be shared without additional new sharing. I think I can't do this in SwiftData (would be the best solution for me as all the current app is based on SwiftDaa) and that I need to use move to CoreData. Is that correct? Or does a mixed solution may be possible (ie .storage with SWiftData and sharing with CoreData)? It seems that “Zone Wide Sharing” could be the solution? But I can't find a sufficiently comprehensive example and I wasn't able to make something working. Ultimately, I realize that this is not a very common use case. With the ZoneWide Sharing does it means that we must do a affectedStores or
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
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
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
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
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
SwiftData with shared and private containers
I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container. So firstly, a big request to any Apple devs reading, for this to be a thing! Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData? Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?
12
0
4.0k
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 App stuck in status Waiting for Review since Feb 9
Alright, so I'm gonna send an email out to Eddy, Matt and Susan. If anyone wants to be copied, paste your email address here. This is just beyond belief. It is unfortunate we have to let Apple leadership know this service is broken and most probably call out people (sadly). This sort of delay is severely severed my relationship with customers and users. I plan to send the email out over the week-end
Replies
Boosts
Views
Activity
3w
Reply to Significantly Delayed App Review
Alright, so I'm gonna send an email out to Eddy, Matt and Susan. If anyone wants to be copied, paste your email address here. This is just beyond belief. It is unfortunate we have to let Apple leadership know this service is broken and most probably call out people (sadly). This sort of delay is severely severed my relationship with customers and users. I plan to send the email out over the week-end.
Replies
Boosts
Views
Activity
3w
Reply to NSFileManager getRelationship:ofDirectoryAtURL:toItemAtURL:error: returning NSURLRelationshipSame for Different Directories
Very interesting info! I can understand that thinking, but it's not the system’s perspective. The system’s view here is that the file reference is considered more authoritative than the path. I actually don't have a strong opinion about file reference urls vs. file path urls but from my perspective in the sample it is clear after the second call to createDirectoryAtURL:..., when that method returns, the fileReferenceURL left lingering in that untitleFour instance is pointing to to the wrong folder based on the fact that I fed that URL directly into a method to create a folder, the operation succeeded, yet there is still a chance to accidentally access a completely different folder through that very same instance going through the cached fileReferenceURL. MacOS itself is heavily still reliant on path, but fileReferenceURLs are the closest construct we have to an API that doesn't fall into this trap. Yea. You can't even create a file without a path so there is that. File reference urls are great at certain thin
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
4w
Reply to FileManager.replaceItemAt(_:withItemAt:) fails sporadically on ubiquitous items
Out of curiosity, I just tested this, and I still see the bug. To see it yourself, just use the code from my first post but change the savingURL accessor to use a security-scoped bookmark, as follows: To be honest, that was basically a blind (well, slightly educated...) guess. To be honest, the whole combination of factors is fairly odd (timing is random, failure self-corrects, etc.). One thing to pass along— I just did a bit of testing with retrying the copy, and clearing the error seems to be tied to TIME, not retry count. If you decide to go the retry route, you may want to delay the save for a second or so instead of just retrying over and over. I’m actually doing (b), since this is very fast on copy-on-write volumes such as APFS even for large files. (Copy-to-temp file is almost instant.) I think very fast actually understates how significant the performance difference is. As an industry, I'm not sure we've really processed how constant-time copying should change file management. For slower volumes, much
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
4w
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
4w
Reply to Sharing all container content
I want to share all the content of a CloudKit database at once between different iCloud accounts. For example, to manage products storage between users. Once the database has been shared or an invitation has been accepted, any additions/modifications/deletions to storage or products must be shared between all users without additional sharing. To be short after the first sharing, everything must be shared without additional new sharing. I think I can't do this in SwiftData (would be the best solution for me as all the current app is based on SwiftDaa) and that I need to use move to CoreData. Is that correct? Or does a mixed solution may be possible (ie .storage with SWiftData and sharing with CoreData)? It seems that “Zone Wide Sharing” could be the solution? But I can't find a sufficiently comprehensive example and I wasn't able to make something working. Ultimately, I realize that this is not a very common use case. With the ZoneWide Sharing does it means that we must do a affectedStores or
Replies
Boosts
Views
Activity
Mar ’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
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
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
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
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
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
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
SwiftData with shared and private containers
I was hoping for an update of SwiftData which adopted the use of shared and public CloudKit containers, in the same way it does for the private CloudKit container. So firstly, a big request to any Apple devs reading, for this to be a thing! Secondly, what would be a sensible way of adding a shared container in CloudKit to an existing app that is already using SwiftData? Would it be possible to use the new DataStore method to manage CloudKit syncing with a public or shared container?
Replies
12
Boosts
0
Views
4.0k
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