Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary
I'm running into a crash when trying to delete an item from a list that's loaded using SwiftData. The app works fine when selecting or displaying the data, but the moment I confirm a deletion, it crashes with this error: SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary This happens right after I delete an item from the list using modelContext.delete(). I’ve double-checked that the item exists and is valid, and I'm not sure what I'm doing wrong. The data is loaded using @Query and everything seems normal until deletion. For further information, I have tried this on a new IOS project where I have one super Model class with a cascading relationship on a child class. When trying to delete the parent class while connected to one or more children, it still gives me the error. The same thing is happening with my original project. Class A has a relationship (cascading) with Class B. Attempting to delete Class A while th
2
0
225
May ’25
SwiftData + CloudKit causes watchOS app termination during WKExtendedRuntimeSession (FB17685611)
Hi all, I’m encountering a consistent issue with SwiftData on watchOS when using CloudKit sync. After enabling: let config = ModelConfiguration(schema: schema, cloudKitDatabase: .automatic) …the app terminates ~30–60 seconds into a WKExtendedRuntimeSession. This happens specifically when: Always-On Display is OFF The iPhone is disconnected or in Airplane Mode The app is running in a WKExtendedRuntimeSession (e.g., used for meditation tracking) The Xcode logs show a warning: Background Task (CoreData: CloudKit Setup), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. It appears CloudKit sync setup is being triggered automatically and flagged by the system as an unmanaged long-running task, leading to termination. Workaround: Switching to: let config = ModelConfiguration(schema: schema, cloudKitDatabase: .none) …prevents the issue entirely — no background task warning, no crash. Feedback ID submitted: FB17685611 Just wanted to check if other
1
0
277
May ’25
SwiftData: SwiftData.PersistentIdentifierImplementation) was remapped to a temporary identifier during save
I'm seeing a lot of these in my logs: PersistentIdentifier PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-swiftdata://Course/BC9CF99A-DE6A-46F1-A18D-8034255A56D8), implementation: SwiftData.PersistentIdentifierImplementation) was remapped to a temporary identifier during save: PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata:///Course/t58C849CD-D895-4773-BF53-3F63CF48935B210), implementation: SwiftData.PersistentIdentifierImplementation). This is a fatal logic error in DefaultStore ... though everything seems to work. Does anyone know what this means in this context? Anything I can do to not have this appear?
9
0
2.0k
May ’25
CoreData error: SQLCore dispatchRequest: no such table: ZAPPSETTINGS. I/O error opening
Issue with SwiftData: “no such table: ZAPPSETTINGS” and SQLite I/O error on app launch Hello, I’m encountering persistent errors with SwiftData in my SwiftUI app related to Core Data’s underlying SQLite database. Despite defining my models correctly, the app fails to initialize the persistent store, throwing the following error on startup: CoreData error: SQLCore dispatchRequest: no such table: ZAPPSETTINGS. I/O error opening database at /.../default.store. SQLite error code:1, NSSQLiteErrorDomain=1. File “default.store” couldn’t be opened. Context The error only appears concerning my AppSettings model. I have another model, LocationPoint, which appears correctly defined and used. I have tried deleting the app, resetting the device, and cleaning builds but the error persists. The error message suggests the database file is present but the table for ZAPPSETTINGS (the Core Data table for AppSettings) does not exist. Code Samples Main App Entry import SwiftData import SwiftUI @main str
1
0
127
May ’25
Reply to SwiftData crash on fetch
The logs after a failed migration could maybe be relevant: CoreData: annotation: Completed persistent history metadata tables update CoreData: annotation: Updating metadata CoreData: annotation: Finished updating metadata CoreData: annotation: Committing formal transaction CoreData: annotation: Finished committing formal transaction CoreData: annotation: Checkpointing WAL journal CoreData: annotation: Finished checkpointing WAL journal CoreData: annotation: Successfully completed lightweight migration on connection CoreData: annotation: Migration step 0.0 'Total migration time (on connection)' took 0.02 seconds CoreData: annotation: (migration) in-place migration completed successfully in 0.02 seconds Did migrate to stage 8 CoreData: annotation: (migration) Automatic schema migration succeeded for store at 'file:///var/mobile/Containers/Data/Application/74E75823-0F85-4194-A84D-B180739009BB/Library/Application%20Support/default.store' with migration stage: SwiftData/PersistentModel.swift:734: Fatal e
May ’25
SwiftData assertionFailure crash in release builds?
I have an issue in my app, where the crashing frame is an assertionFailure in BackingData.set inside SwiftData framework. My own app doesn't appear until frame 14. I have no idea what causes this, or even how to create a reproducible project as this only happens on some devices. The frame prior to the assertionFailure is this: #1 (null) in BackingData.set(any:value:) () It seems like there is a backing data encoding happening in my Model class, and some value is causing it to fail. The model being accessed is through a relationship, and the frame in the app crashing is along the lines of Text(parent.child.name) Obviously, something is wrong in how I have made child, but the part that stand out to me is the assertionFailure in a release build
4
0
127
May ’25
App Stuck In Review For 8 Days, Repeated Board Escalations Severely Impacting Release Cycle
Dear App Review Team, I am writing to express deep concern over the repeated and prolonged delays the app is facing during the App Review process. Once again, a recent build—submitted on May 12—has been stuck in the In Review state for over a week. I have been informed that, as has become routine, the submission has been escalated to the App Review Board without any clear timeline or communication. This is not an isolated incident. Nearly every feature update submitted is referred to the board, resulting in unpredictable, weeks-long delays that severely disrupt the development and release cycle. These escalations consistently happen without clear reasoning, and without any proactive outreach or follow-up from the review team. The app is currently one of the highest-performing indie titles on the visionOS App Store, and I am committed to delivering the highest quality experience for users on Apple platforms. However, the current review process is making it increasingly difficult to operate responsibly or effic
1
0
134
May ’25
Reply to Strange Live Activity Occurrence Behavior
I finally figured this out. It's really weird but I found the issue. In the initializer of the TimelineProvider struct of the UpNextWidget(), I created a SwiftData modelContainer. Once I remove that from the initializer to the function that will need the ModelContext, it works reliably as expected. Obviously this can not be intended behavior. I filed a feedback with a sample project based on the template for Live Activities that illustrates the problem. FB17655658
May ’25
DeviceCheck.generateToken, Error: com.apple.devicecheck.error 0
Dear Apple Developer Support Team, We are experiencing a recurring issue with the DeviceCheck API where the following error is being returned: com.apple.devicecheck.error 0 Upon analyzing our logs, we have noticed that this error occurs significantly more often when users are connected to Wi-Fi networks, compared to mobile networks. This leads us to suspect that there might be a relationship between Wi-Fi configuration and the DeviceCheck service’s ability to generate or validate tokens. We would like to know: Is this error code (0) known to be caused by specific types of network behavior or misconfigurations on Wi-Fi networks (e.g., DNS filtering, firewall restrictions, proxy servers)? Are there any recommended best practices for ensuring reliable DeviceCheck API communication over Wi-Fi networks? Additionally, could you please clarify what general conditions could trigger this com.apple.devicecheck.error 0? The lack of specific documentation makes debugging this issue difficult from our side. Any g
2
0
161
May ’25
Migrating schemas in SwiftData + CloudKit
Hello, I’m struggling to go from unversioned data model in SwiftData, to starting to version it. Some FYI: I’m using CloudKit I’m using a widget, where I also pass in my data model and setup my container, this is shared over a group container/app group. My migration is very simple, I’m adding a property which is not optional ( has default value set, and a default value in initialiser ). Model: @Model class NicotineModel { var nicotineType: NicotineType = NicotineType.snus var startDate: Date = Date() + 30 var spendingAmount: Int = 0 var nicotinePerDay: Int = 0 var quittingMethod: QuittingMethod = QuittingMethod.coldTurkey // this is the change in the model, V1 doesn't have the quittingMethod property var setupComplete: Bool = false I’ve tried with: static let migrateV1toV2 = MigrationStage.lightweight( fromVersion: SchemaV1.self, toVersion: SchemaV2.self ) But also static let migrateV1toV2 = MigrationStage.custom( fromVersion: SchemaV1.self, toVersion: SchemaV2.self, willMigrate: nil, didMigrate: { c
3
0
963
Sep ’24
Reply to SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary
I have the same issue in my app, which a user pointed out to me yesterday. However, in my case, the crash only occurs when a widget on the Home Screen is using the SwiftData model object I'm trying to delete. Does your app use widgets, out of interest?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary
I'm running into a crash when trying to delete an item from a list that's loaded using SwiftData. The app works fine when selecting or displaying the data, but the moment I confirm a deletion, it crashes with this error: SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary This happens right after I delete an item from the list using modelContext.delete(). I’ve double-checked that the item exists and is valid, and I'm not sure what I'm doing wrong. The data is loaded using @Query and everything seems normal until deletion. For further information, I have tried this on a new IOS project where I have one super Model class with a cascading relationship on a child class. When trying to delete the parent class while connected to one or more children, it still gives me the error. The same thing is happening with my original project. Class A has a relationship (cascading) with Class B. Attempting to delete Class A while th
Replies
2
Boosts
0
Views
225
Activity
May ’25
SwiftData + CloudKit causes watchOS app termination during WKExtendedRuntimeSession (FB17685611)
Hi all, I’m encountering a consistent issue with SwiftData on watchOS when using CloudKit sync. After enabling: let config = ModelConfiguration(schema: schema, cloudKitDatabase: .automatic) …the app terminates ~30–60 seconds into a WKExtendedRuntimeSession. This happens specifically when: Always-On Display is OFF The iPhone is disconnected or in Airplane Mode The app is running in a WKExtendedRuntimeSession (e.g., used for meditation tracking) The Xcode logs show a warning: Background Task (CoreData: CloudKit Setup), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. It appears CloudKit sync setup is being triggered automatically and flagged by the system as an unmanaged long-running task, leading to termination. Workaround: Switching to: let config = ModelConfiguration(schema: schema, cloudKitDatabase: .none) …prevents the issue entirely — no background task warning, no crash. Feedback ID submitted: FB17685611 Just wanted to check if other
Replies
1
Boosts
0
Views
277
Activity
May ’25
SwiftData: SwiftData.PersistentIdentifierImplementation) was remapped to a temporary identifier during save
I'm seeing a lot of these in my logs: PersistentIdentifier PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-swiftdata://Course/BC9CF99A-DE6A-46F1-A18D-8034255A56D8), implementation: SwiftData.PersistentIdentifierImplementation) was remapped to a temporary identifier during save: PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata:///Course/t58C849CD-D895-4773-BF53-3F63CF48935B210), implementation: SwiftData.PersistentIdentifierImplementation). This is a fatal logic error in DefaultStore ... though everything seems to work. Does anyone know what this means in this context? Anything I can do to not have this appear?
Replies
9
Boosts
0
Views
2.0k
Activity
May ’25
Reply to CoreData error: SQLCore dispatchRequest: no such table: ZAPPSETTINGS. I/O error opening
You could enable Core Data debug logging (also used by SwiftData) to see if that gives you any important information, see https://www.hackingwithswift.com/quick-start/swiftdata/using-launch-arguments-to-debug-swiftdata-and-core-data
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
May ’25
CoreData error: SQLCore dispatchRequest: no such table: ZAPPSETTINGS. I/O error opening
Issue with SwiftData: “no such table: ZAPPSETTINGS” and SQLite I/O error on app launch Hello, I’m encountering persistent errors with SwiftData in my SwiftUI app related to Core Data’s underlying SQLite database. Despite defining my models correctly, the app fails to initialize the persistent store, throwing the following error on startup: CoreData error: SQLCore dispatchRequest: no such table: ZAPPSETTINGS. I/O error opening database at /.../default.store. SQLite error code:1, NSSQLiteErrorDomain=1. File “default.store” couldn’t be opened. Context The error only appears concerning my AppSettings model. I have another model, LocationPoint, which appears correctly defined and used. I have tried deleting the app, resetting the device, and cleaning builds but the error persists. The error message suggests the database file is present but the table for ZAPPSETTINGS (the Core Data table for AppSettings) does not exist. Code Samples Main App Entry import SwiftData import SwiftUI @main str
Replies
1
Boosts
0
Views
127
Activity
May ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Here is a simple test project: https://github.com/GNiewoehner/swiftdata-test-app On start it creates some dummy data, and fetches them without accessing any relationships. The logs are printed to the console.
Replies
Boosts
Views
Activity
May ’25
Reply to SwiftData crash on fetch
The logs after a failed migration could maybe be relevant: CoreData: annotation: Completed persistent history metadata tables update CoreData: annotation: Updating metadata CoreData: annotation: Finished updating metadata CoreData: annotation: Committing formal transaction CoreData: annotation: Finished committing formal transaction CoreData: annotation: Checkpointing WAL journal CoreData: annotation: Finished checkpointing WAL journal CoreData: annotation: Successfully completed lightweight migration on connection CoreData: annotation: Migration step 0.0 'Total migration time (on connection)' took 0.02 seconds CoreData: annotation: (migration) in-place migration completed successfully in 0.02 seconds Did migrate to stage 8 CoreData: annotation: (migration) Automatic schema migration succeeded for store at 'file:///var/mobile/Containers/Data/Application/74E75823-0F85-4194-A84D-B180739009BB/Library/Application%20Support/default.store' with migration stage: SwiftData/PersistentModel.swift:734: Fatal e
Replies
Boosts
Views
Activity
May ’25
SwiftData assertionFailure crash in release builds?
I have an issue in my app, where the crashing frame is an assertionFailure in BackingData.set inside SwiftData framework. My own app doesn't appear until frame 14. I have no idea what causes this, or even how to create a reproducible project as this only happens on some devices. The frame prior to the assertionFailure is this: #1 (null) in BackingData.set(any:value:) () It seems like there is a backing data encoding happening in my Model class, and some value is causing it to fail. The model being accessed is through a relationship, and the frame in the app crashing is along the lines of Text(parent.child.name) Obviously, something is wrong in how I have made child, but the part that stand out to me is the assertionFailure in a release build
Replies
4
Boosts
0
Views
127
Activity
May ’25
App Stuck In Review For 8 Days, Repeated Board Escalations Severely Impacting Release Cycle
Dear App Review Team, I am writing to express deep concern over the repeated and prolonged delays the app is facing during the App Review process. Once again, a recent build—submitted on May 12—has been stuck in the In Review state for over a week. I have been informed that, as has become routine, the submission has been escalated to the App Review Board without any clear timeline or communication. This is not an isolated incident. Nearly every feature update submitted is referred to the board, resulting in unpredictable, weeks-long delays that severely disrupt the development and release cycle. These escalations consistently happen without clear reasoning, and without any proactive outreach or follow-up from the review team. The app is currently one of the highest-performing indie titles on the visionOS App Store, and I am committed to delivering the highest quality experience for users on Apple platforms. However, the current review process is making it increasingly difficult to operate responsibly or effic
Replies
1
Boosts
0
Views
134
Activity
May ’25
Reply to Strange Live Activity Occurrence Behavior
I finally figured this out. It's really weird but I found the issue. In the initializer of the TimelineProvider struct of the UpNextWidget(), I created a SwiftData modelContainer. Once I remove that from the initializer to the function that will need the ModelContext, it works reliably as expected. Obviously this can not be intended behavior. I filed a feedback with a sample project based on the template for Live Activities that illustrates the problem. FB17655658
Replies
Boosts
Views
Activity
May ’25
Error when running a modelContext rollback
I'm getting the following error message when executing the rollback method in a modelContext, what could be causing this ? SwiftData/ModelSnapshot.swift:46: Fatal error: A ModelSnapshot must be initialized with a known-keys dictionary
Replies
5
Boosts
0
Views
172
Activity
May ’25
Reply to ModelContext.model(for:) returns deleted objects
I'm writing some tests to confirm the behavior of my app, you are actually unit testing SwiftData and not your app. As for the problem, I am not sure it's a bug and that they deliberately keep the object in the ModelContext for a short while to avoid problems for the app using it. The following test would pass though #expect(result.isDeleted)
Replies
Boosts
Views
Activity
May ’25
DeviceCheck.generateToken, Error: com.apple.devicecheck.error 0
Dear Apple Developer Support Team, We are experiencing a recurring issue with the DeviceCheck API where the following error is being returned: com.apple.devicecheck.error 0 Upon analyzing our logs, we have noticed that this error occurs significantly more often when users are connected to Wi-Fi networks, compared to mobile networks. This leads us to suspect that there might be a relationship between Wi-Fi configuration and the DeviceCheck service’s ability to generate or validate tokens. We would like to know: Is this error code (0) known to be caused by specific types of network behavior or misconfigurations on Wi-Fi networks (e.g., DNS filtering, firewall restrictions, proxy servers)? Are there any recommended best practices for ensuring reliable DeviceCheck API communication over Wi-Fi networks? Additionally, could you please clarify what general conditions could trigger this com.apple.devicecheck.error 0? The lack of specific documentation makes debugging this issue difficult from our side. Any g
Replies
2
Boosts
0
Views
161
Activity
May ’25
Migrating schemas in SwiftData + CloudKit
Hello, I’m struggling to go from unversioned data model in SwiftData, to starting to version it. Some FYI: I’m using CloudKit I’m using a widget, where I also pass in my data model and setup my container, this is shared over a group container/app group. My migration is very simple, I’m adding a property which is not optional ( has default value set, and a default value in initialiser ). Model: @Model class NicotineModel { var nicotineType: NicotineType = NicotineType.snus var startDate: Date = Date() + 30 var spendingAmount: Int = 0 var nicotinePerDay: Int = 0 var quittingMethod: QuittingMethod = QuittingMethod.coldTurkey // this is the change in the model, V1 doesn't have the quittingMethod property var setupComplete: Bool = false I’ve tried with: static let migrateV1toV2 = MigrationStage.lightweight( fromVersion: SchemaV1.self, toVersion: SchemaV2.self ) But also static let migrateV1toV2 = MigrationStage.custom( fromVersion: SchemaV1.self, toVersion: SchemaV2.self, willMigrate: nil, didMigrate: { c
Replies
3
Boosts
0
Views
963
Activity
Sep ’24