Search results for

“SwiftData inheritance relationship”

4,986 results found

Post

Replies

Boosts

Views

Activity

Reply to Best practice for centralizing SwiftData query logic and actions in an @Observable manager?
This is untested and probably has problems, but this approximates what I meant: import SwiftData import SwiftUI struct ReadingViewModifier: ViewModifier { @Query private var books: [Book] @State private var manager: ReadingManager func body(content: Content) -> some View { content .environment(.readingManager, manager) .onChange(of: books) { manager.receive(books: books) } } } Inside another component, you can read the manager with: @Environment(.readingManager) private var manger: ReadingManager
1w
Reply to Fatal error on rollback after delete
I managed to create a minimal repro example: import SwiftData import SwiftUI @Model final class ParentModel { var name: String @Relationship(deleteRule: .cascade, inverse: ChildModel1.parent) var children: [ChildModel1]? @Relationship(deleteRule: .cascade, inverse: ChildModel2.parent) var children2: [ChildModel2]? init(name: String) { self.name = name } } @Model final class ChildModel1 { var name: String @Relationship(deleteRule: .nullify) var parent: ParentModel? init(name: String) { self.name = name } } @Model final class ChildModel2 { var name: String @Relationship(deleteRule: .nullify) var parent: ParentModel? init(name: String) { self.name = name } } struct ContentView: View { @Environment(.modelContext) private var modelContext var body: some View { List { Button(Create parent with children) { createParentWithChildren() } Button(Delete) { delete() } } } func createParentWithChildren() { let parent = ParentModel(name: Parent) let child1 = ChildModel1(name: Chi
1w
Fatal error on rollback after delete
I encountered an error when trying to rollback context after deleting some model with multiple one-to-many relationships when encountered a problem later in a deleting method and before saving the changes. Something like this: do { // Fetch model modelContext.delete(model) // Do some async work that potentially throws try modelContext.save() } catch { modelContext.rollback() } When relationship is empty - the parent has no children - I can safely delete and rollback with no issues. However, when there is even one child when I call even this code: modelContext.delete(someModel) modelContext.rollback() I'm getting a fatal error: SwiftData/ModelSnapshot.swift:46: Fatal error: Unexpected backing data for snapshot creation: SwiftData._FullFutureBackingData I use ModelContext from within the ModelActor but using mainContext changes nothing. My ModelContainer is quite simple and problem occurs on both in-memory and persistent storage, with or without CloudKit database being enable
2
0
104
1w
Reply to Crash on App Clip Subtitle Focus
Thanks for the post. I don’t think you have provided much information to be able to help you. Can you provide a focused sample of how you use App Clips? Are you using Xcode, can you create a new sample project that reproduces the issue using the steps below? App Clips are built as a separate target within your existing iOS app project. Open your project in Xcode. Go to File > New > Target. Select App Clip under the iOS tab. Name your App Clip and ensure it is embedded in your main application target. App Clips rely heavily on Universal Links to securely verify the relationship between your website and your app. Add the Associated Domains capability to both your main app target and your App Clip target. Add your domain using the appclips: prefix. Example: appclips:example.com Update the apple-app-site-association (AASA) file on your web server to include an appclips dictionary. { appclips: { apps: [..Clip] } } Please follow this great documentation: https://developer.apple.com/design/human-inter
1w
SwiftData ModelContext Pollution with Multiple ModelContainers and Schemas
I have two different VersionedSchema accessed via two different and distinct in-memory ModelContainers. However, both schemas have a model named Item. LocalSchema.Item and RemoteSchema.Item have slightly different properties. If I create and save RemoteSchema.Item in one context then I cannot create and save LocalSchema.Item in a different context due to missing origin property. enum LocalSchema: VersionedSchema { static var versionIdentifier: Schema.Version = .init(1, 0, 0) static var models: [any PersistentModel.Type] = [ Item.self ] @Model class Item { @Attribute(.unique) var title: String var created: Date var modified: Date init(title: String, created: Date, modified: Date) { self.title = title self.created = created self.modified = modified } } } enum RemoteSchema: VersionedSchema { static var versionIdentifier: Schema.Version = .init(1, 0, 0) static var models: [any PersistentModel.Type] = [ Item.self ] @Model class Item { var title: String var created: Date var modified: Date var origin: String init(t
4
0
105
1w
Reply to Using StoreKit from an AUv3 plugin that can be loaded in-process
[quote='880359022, timboudreau, /thread/818192?answerId=880359022#880359022, /profile/timboudreau'] Seems pretty byzantine and fragile [/quote] Yeah. I considered this approach before I replied to you yesterday, but I concluded that: I’m not sure if it’s possible to pull off [1]. And even if it is, it’s likely to be very fragile. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Your appex is sandboxed so: It can’t spawn your app’s executable as a child process because that would require reinitialising the sandbox, something that the system specifically blocks. See App Sandbox Inheritance within Resolving Trusted Execution Problems. It should be able to launch the app with NSWorkspace, but NSWorkspace doesn’t honour all of its configuration when it’s called by a sandboxed process.
Topic: Media Technologies SubTopic: Audio Tags:
2w
Reply to Swift Data Recovery
First of all you should check the console and check if you get any warning messages when you run the app and access your data. if nothing shows up then you can turn on sql debug logging to help you figure out what is happening. See this article from the Hacking With Swift website on how to do that, https://www.hackingwithswift.com/quick-start/swiftdata/using-launch-arguments-to-debug-swiftdata-and-core-data
2w
Reply to Provisioning profile missing entitlement: com.apple.developer.icloud
Thank you for your replies. Unfortunately, this didn't help either. I developed an app with SwiftDate in a GroupContainer. The data model is stable, and all relationships are optional. The next step should be to switch to an iCloudContainer. Both computers are on the same network and have internet access and access to the developer account. I disabled and re-enabled automatic signing. No change. A comparison of the project.pbxproj files showed two new lines in the non-functional project: 913a913 CODE_SIGN_IDENTITY = Apple Development; 948a949 PROVISIONING_PROFILE_SPECIFIER = ; I manually deleted these two lines and restarted Xcode. There was no change in behavior; the same error occurred. I also manually downloaded the profile from the developer website and tried to sign it manually. But this deployment profile has the same error again: Entitlements: 8 included, 1 Missing What surprises me is that the working version on the MacBook lists 12 entitlements. The entitlements are identical on both systems
2w
Notarization submissions stuck "In Progress" for 10 days
All of my notarization submissions have been stuck at In Progress for up to 10 days. I have 6 submissions spanning from March 4 to March 11, 2026, and none of them have completed or returned any errors. Affected submissions: dbf20b57-0073-444a-b09a-ac6747b7398e (submitted Mar 4) — In Progress d5886683-be64-455c-805d-cd8b12bbcd35 (submitted Mar 4) — In Progress 10bfa709-da17-49cf-9c89-63f93b5fb756 (submitted Mar 4) — In Progress e8d0866e-43f8-4a18-8129-64e6c5d3895a (submitted Mar 9) — In Progress f9526f25-5650-4c45-98ae-d778c58a2ffa (submitted Mar 9) — In Progress 82ec211f-9179-41fd-afe0-937c9b2c2750 (submitted Mar 11) — In Progress Running `notarytool log` returns Submission log is not yet available. Team ID: CB4U5M6U9H It is an Electron-based app built with electron-builder. Steps taken to ensure compliance: Signed with a valid Developer ID Application certificate Hardened runtime enabled (hardenedRuntime: true) Proper entitlements configured (com.apple.security.cs.allow-jit, com.apple.security.cs.allow-unsi
1
0
337
2w
Reply to SwiftData Models and SortDesc. Only Work in One Swift File
I saw this post, but have not found anything there about the one file works, separate files crashes aspect. So I submitted a post. But in general yes, it is also about sorting on optional nested relationships. @nilsn26: Thanks for your feedback report and confirmation. I don't have a clear answer about why putting the models and the sort logic in a same Swift file avoids the crash either, but I think the technical nature here is that KeyPath.appending can't forward optionality, which is a known issue under the investigation of the Swift team. Best, —— Ziqiao Chen  Worldwide Developer Relations.
3w
Reply to FileManager.replaceItemAt(_:withItemAt:) fails sporadically on ubiquitous items
What's the best way of being careful about this, or do you just mean by using the item replacement directory where possible? As far as I know, there are only two ways of getting a temp directory: Everything you've described sounds like you're on the right track. The big thing is just not making assumption about the relationship between directories (/tmp/ and home are on the same volume) or capabilities (home directories are ALWAYS on volumes that support cloning). The killer here is the long tail, as there are just SO many different edge cases. LibZip is much faster on a volume that supports cloning Interesting. Are you primarily editing the contents of the zip file (so you end up modifying the data inside, but don't really change it's overall size or structure)? Cloning is a huge help if you can clone the contents and then modify but if your modifications end up changing the fundamental contents, then I wouldn't expect the difference to be nearly as large. At large scale, this eventually devolves to
Topic: App & System Services SubTopic: Core OS Tags:
3w
Reply to Waiting for Review: TestFlight 25+ days, Production 10 days, no communication.
Similar situation. First time app, macOS and iOS versions, no login, no account, no server - just plain SwiftData, CloudKit, and one in-app purchase to unlock lifetime access. TestFlight: macOS build: submitted Feb 09, 2026 -> approved Feb 11, 2026 iOS build: submitted Feb 09, 2026 -> waiting -> re-submitted by incrementing build number Feb 18, 2026 -> still waiting, status on Mar 12, 2026: 'Waiting for Review' In-app purchase: didn't require submission I got enough feedback from my macOS beta testing that I decided to go ahead with the final app approval submission. Production: macOS build: submitted Mar 06, 2026 -> approved Mar 09, 2026 iOS build: submitted Mar 06, 2026 -> still waiting, status on Mar 12, 2026: 'Waiting for Review' In-app purchase: status on Mar 12, 2026: 'In Review' Without the IAP approval, it doesn't even make sense to announce my macOS release to my network because the app will just lock up after 14 days if they're unable to purchase. Why are things happening
3w
Reply to Data Disappeared
Thanks for taking the time to share your question here. After reading your question, I’m finding myself with more questions than answers right now. Could you tell me what database you’re using (SwiftData)? Also, please specify the programming languages, frameworks, or tools you’re working with. The more details you can share, including code snippets and the versions of the tools you’re using (like Xcode, macOS, iOS, etc.), the better. Lastly, could you let me know which platform you’re aiming for? I'm sure someone in the community will be able to help once you have a chance to update your post. Albert Pascual
  Worldwide Developer Relations.
3w
Reply to Best practice for centralizing SwiftData query logic and actions in an @Observable manager?
This is untested and probably has problems, but this approximates what I meant: import SwiftData import SwiftUI struct ReadingViewModifier: ViewModifier { @Query private var books: [Book] @State private var manager: ReadingManager func body(content: Content) -> some View { content .environment(.readingManager, manager) .onChange(of: books) { manager.receive(books: books) } } } Inside another component, you can read the manager with: @Environment(.readingManager) private var manger: ReadingManager
Replies
Boosts
Views
Activity
1w
Reply to Fatal error on rollback after delete
Thanks for filing the feedback report (FB22325366). Yeah, that does look like an issue on the framework side. I can reproduce the crash without the need of adding a second relationship with Xcode 26.4 (17E192) + iOS 26.4 (23E244) Simulator. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
1w
Reply to Fatal error on rollback after delete
I managed to create a minimal repro example: import SwiftData import SwiftUI @Model final class ParentModel { var name: String @Relationship(deleteRule: .cascade, inverse: ChildModel1.parent) var children: [ChildModel1]? @Relationship(deleteRule: .cascade, inverse: ChildModel2.parent) var children2: [ChildModel2]? init(name: String) { self.name = name } } @Model final class ChildModel1 { var name: String @Relationship(deleteRule: .nullify) var parent: ParentModel? init(name: String) { self.name = name } } @Model final class ChildModel2 { var name: String @Relationship(deleteRule: .nullify) var parent: ParentModel? init(name: String) { self.name = name } } struct ContentView: View { @Environment(.modelContext) private var modelContext var body: some View { List { Button(Create parent with children) { createParentWithChildren() } Button(Delete) { delete() } } } func createParentWithChildren() { let parent = ParentModel(name: Parent) let child1 = ChildModel1(name: Chi
Replies
Boosts
Views
Activity
1w
Fatal error on rollback after delete
I encountered an error when trying to rollback context after deleting some model with multiple one-to-many relationships when encountered a problem later in a deleting method and before saving the changes. Something like this: do { // Fetch model modelContext.delete(model) // Do some async work that potentially throws try modelContext.save() } catch { modelContext.rollback() } When relationship is empty - the parent has no children - I can safely delete and rollback with no issues. However, when there is even one child when I call even this code: modelContext.delete(someModel) modelContext.rollback() I'm getting a fatal error: SwiftData/ModelSnapshot.swift:46: Fatal error: Unexpected backing data for snapshot creation: SwiftData._FullFutureBackingData I use ModelContext from within the ModelActor but using mainContext changes nothing. My ModelContainer is quite simple and problem occurs on both in-memory and persistent storage, with or without CloudKit database being enable
Replies
2
Boosts
0
Views
104
Activity
1w
Reply to SwiftData ModelContext Pollution with Multiple ModelContainers and Schemas
Thanks for filing the feedback report (FB22310365). It seems to be a known issue that is under the investigation of the SwiftData folks. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
1w
Reply to Crash on App Clip Subtitle Focus
Thanks for the post. I don’t think you have provided much information to be able to help you. Can you provide a focused sample of how you use App Clips? Are you using Xcode, can you create a new sample project that reproduces the issue using the steps below? App Clips are built as a separate target within your existing iOS app project. Open your project in Xcode. Go to File > New > Target. Select App Clip under the iOS tab. Name your App Clip and ensure it is embedded in your main application target. App Clips rely heavily on Universal Links to securely verify the relationship between your website and your app. Add the Associated Domains capability to both your main app target and your App Clip target. Add your domain using the appclips: prefix. Example: appclips:example.com Update the apple-app-site-association (AASA) file on your web server to include an appclips dictionary. { appclips: { apps: [..Clip] } } Please follow this great documentation: https://developer.apple.com/design/human-inter
Replies
Boosts
Views
Activity
1w
SwiftData ModelContext Pollution with Multiple ModelContainers and Schemas
I have two different VersionedSchema accessed via two different and distinct in-memory ModelContainers. However, both schemas have a model named Item. LocalSchema.Item and RemoteSchema.Item have slightly different properties. If I create and save RemoteSchema.Item in one context then I cannot create and save LocalSchema.Item in a different context due to missing origin property. enum LocalSchema: VersionedSchema { static var versionIdentifier: Schema.Version = .init(1, 0, 0) static var models: [any PersistentModel.Type] = [ Item.self ] @Model class Item { @Attribute(.unique) var title: String var created: Date var modified: Date init(title: String, created: Date, modified: Date) { self.title = title self.created = created self.modified = modified } } } enum RemoteSchema: VersionedSchema { static var versionIdentifier: Schema.Version = .init(1, 0, 0) static var models: [any PersistentModel.Type] = [ Item.self ] @Model class Item { var title: String var created: Date var modified: Date var origin: String init(t
Replies
4
Boosts
0
Views
105
Activity
1w
Reply to Using StoreKit from an AUv3 plugin that can be loaded in-process
[quote='880359022, timboudreau, /thread/818192?answerId=880359022#880359022, /profile/timboudreau'] Seems pretty byzantine and fragile [/quote] Yeah. I considered this approach before I replied to you yesterday, but I concluded that: I’m not sure if it’s possible to pull off [1]. And even if it is, it’s likely to be very fragile. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Your appex is sandboxed so: It can’t spawn your app’s executable as a child process because that would require reinitialising the sandbox, something that the system specifically blocks. See App Sandbox Inheritance within Resolving Trusted Execution Problems. It should be able to launch the app with NSWorkspace, but NSWorkspace doesn’t honour all of its configuration when it’s called by a sandboxed process.
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
2w
Reply to Swift Data Recovery
First of all you should check the console and check if you get any warning messages when you run the app and access your data. if nothing shows up then you can turn on sql debug logging to help you figure out what is happening. See this article from the Hacking With Swift website on how to do that, https://www.hackingwithswift.com/quick-start/swiftdata/using-launch-arguments-to-debug-swiftdata-and-core-data
Replies
Boosts
Views
Activity
2w
Reply to Provisioning profile missing entitlement: com.apple.developer.icloud
Thank you for your replies. Unfortunately, this didn't help either. I developed an app with SwiftDate in a GroupContainer. The data model is stable, and all relationships are optional. The next step should be to switch to an iCloudContainer. Both computers are on the same network and have internet access and access to the developer account. I disabled and re-enabled automatic signing. No change. A comparison of the project.pbxproj files showed two new lines in the non-functional project: 913a913 CODE_SIGN_IDENTITY = Apple Development; 948a949 PROVISIONING_PROFILE_SPECIFIER = ; I manually deleted these two lines and restarted Xcode. There was no change in behavior; the same error occurred. I also manually downloaded the profile from the developer website and tried to sign it manually. But this deployment profile has the same error again: Entitlements: 8 included, 1 Missing What surprises me is that the working version on the MacBook lists 12 entitlements. The entitlements are identical on both systems
Replies
Boosts
Views
Activity
2w
Notarization submissions stuck "In Progress" for 10 days
All of my notarization submissions have been stuck at In Progress for up to 10 days. I have 6 submissions spanning from March 4 to March 11, 2026, and none of them have completed or returned any errors. Affected submissions: dbf20b57-0073-444a-b09a-ac6747b7398e (submitted Mar 4) — In Progress d5886683-be64-455c-805d-cd8b12bbcd35 (submitted Mar 4) — In Progress 10bfa709-da17-49cf-9c89-63f93b5fb756 (submitted Mar 4) — In Progress e8d0866e-43f8-4a18-8129-64e6c5d3895a (submitted Mar 9) — In Progress f9526f25-5650-4c45-98ae-d778c58a2ffa (submitted Mar 9) — In Progress 82ec211f-9179-41fd-afe0-937c9b2c2750 (submitted Mar 11) — In Progress Running `notarytool log` returns Submission log is not yet available. Team ID: CB4U5M6U9H It is an Electron-based app built with electron-builder. Steps taken to ensure compliance: Signed with a valid Developer ID Application certificate Hardened runtime enabled (hardenedRuntime: true) Proper entitlements configured (com.apple.security.cs.allow-jit, com.apple.security.cs.allow-unsi
Replies
1
Boosts
0
Views
337
Activity
2w
Reply to SwiftData Models and SortDesc. Only Work in One Swift File
I saw this post, but have not found anything there about the one file works, separate files crashes aspect. So I submitted a post. But in general yes, it is also about sorting on optional nested relationships. @nilsn26: Thanks for your feedback report and confirmation. I don't have a clear answer about why putting the models and the sort logic in a same Swift file avoids the crash either, but I think the technical nature here is that KeyPath.appending can't forward optionality, which is a known issue under the investigation of the Swift team. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
3w
Reply to FileManager.replaceItemAt(_:withItemAt:) fails sporadically on ubiquitous items
What's the best way of being careful about this, or do you just mean by using the item replacement directory where possible? As far as I know, there are only two ways of getting a temp directory: Everything you've described sounds like you're on the right track. The big thing is just not making assumption about the relationship between directories (/tmp/ and home are on the same volume) or capabilities (home directories are ALWAYS on volumes that support cloning). The killer here is the long tail, as there are just SO many different edge cases. LibZip is much faster on a volume that supports cloning Interesting. Are you primarily editing the contents of the zip file (so you end up modifying the data inside, but don't really change it's overall size or structure)? Cloning is a huge help if you can clone the contents and then modify but if your modifications end up changing the fundamental contents, then I wouldn't expect the difference to be nearly as large. At large scale, this eventually devolves to
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
3w
Reply to Waiting for Review: TestFlight 25+ days, Production 10 days, no communication.
Similar situation. First time app, macOS and iOS versions, no login, no account, no server - just plain SwiftData, CloudKit, and one in-app purchase to unlock lifetime access. TestFlight: macOS build: submitted Feb 09, 2026 -> approved Feb 11, 2026 iOS build: submitted Feb 09, 2026 -> waiting -> re-submitted by incrementing build number Feb 18, 2026 -> still waiting, status on Mar 12, 2026: 'Waiting for Review' In-app purchase: didn't require submission I got enough feedback from my macOS beta testing that I decided to go ahead with the final app approval submission. Production: macOS build: submitted Mar 06, 2026 -> approved Mar 09, 2026 iOS build: submitted Mar 06, 2026 -> still waiting, status on Mar 12, 2026: 'Waiting for Review' In-app purchase: status on Mar 12, 2026: 'In Review' Without the IAP approval, it doesn't even make sense to announce my macOS release to my network because the app will just lock up after 14 days if they're unable to purchase. Why are things happening
Replies
Boosts
Views
Activity
3w
Reply to Data Disappeared
Thanks for taking the time to share your question here. After reading your question, I’m finding myself with more questions than answers right now. Could you tell me what database you’re using (SwiftData)? Also, please specify the programming languages, frameworks, or tools you’re working with. The more details you can share, including code snippets and the versions of the tools you’re using (like Xcode, macOS, iOS, etc.), the better. Lastly, could you let me know which platform you’re aiming for? I'm sure someone in the community will be able to help once you have a chance to update your post. Albert Pascual
  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
3w