Search results for

“SwiftData inheritance relationship”

4,981 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftData & CloudKit: Arrays of Codable Structs Causing NSKeyedUnarchiveFromData Error
I switch to using Data with Transient computed property and it still is showing the same error logged to the console: import SwiftData @Model final class ProtocolMedication { var uuid: UUID = UUID() var createdAt: Date = Date() var frequency: SchedulingFrequency = SchedulingFrequency.atRegularIntervals var interval: SchedulingInterval = SchedulingInterval(days: 1) var startDate: Date = Date() var timesData: Data? var dayOfWeekSelection: DayOfWeekSelection = DayOfWeekSelection(days: [1]) var injectionRotationConfig: InjectionRotationConfig = InjectionRotationConfig() var medicationConcentration: MedicationConcentration = MedicationConcentration(value: nil, unit: nil) var medication: Medication? @Relationship(deleteRule: .cascade, inverse: ScheduledDose.protocolMed) var _scheduledDoses: [ScheduledDose]? @Relationship(deleteRule: .cascade, inverse: DoseLog.protocolMed) var _doseLogs: [DoseLog]? @Transient var times: [SchedulingTime] { get { guard let data = timesData else { return [] }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to SwiftData & CloudKit: Arrays of Codable Structs Causing NSKeyedUnarchiveFromData Error
Do you have a feedback report yet? If not, I’d suggest that you file one and share your report ID here. For a workaround, you might consider making SchedulingTime a SwiftData model, if that is appropriate, and relating it to ProtocolMedication with a too-many relationship. You can also consider using Data directly for persistence, and providing a transient (@Transient) property for the access to the struct array (only) in memory. A transient property can't be used in a query though. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
SwiftUI TextField input is super laggy for SwiftData object
have a SwiftUI View where I can edit financial transaction information. The data is stored in SwiftData. If I enter a TextField element and start typing, it is super laggy and there are hangs of 1-2 seconds between each input (identical behaviour if debugger is detached). On the same view I have another TextField that is just attached to a @State variable of that view and TextField updates of that value work flawlessly. So somehow the hangs must be related to my SwiftData object but I cannot figure out why. This used to work fine until a few months ago and then I could see the performance degrading. I have noticed that when I use a placeholder variable like @State private var transactionSubject: String = and link that to the TextField, the performance is back to normal. I am then using .onSubmit { self.transaction.subject = self.transactionSubject } to update the value in the end but this again causes a 1 s hang. :/ Below the original code sample with some unnecessary stuff removed: struct
2
0
194
Sep ’25
SwiftData - Cloudkit stopped syncing
I have an app that from day 1 has used Swiftdata and successfully sync'd across devices with Cloudkit. I have added models to the data in the past and deployed the schema and it continued to sync across devices. Sometime I think in June.2025 I added a new model and built out the UI to display and manage it. I pushed a version to Test Flight (twice over a matter of 2 versions and a couple of weeks) and created objects in the new model in Test Flight versions of the app which should push the info to Cloudkit to update the schema. When I go to deploy the schema though there are no changes. I confirmed in the app that Cloudkit is selected and it's point to the correct container. And when I look in Cloudkit the new model isn't listed as an indes. I've pushed deploy schema changes anyway (more than once) and now the app isn't sync-ing across devices at all (even the pre-existing models aren't sync-ing across devices). I even submitted the first updated version to the app store and it was approved and relea
3
0
251
Sep ’25
Reply to SwiftData - Cloudkit stopped syncing
In CloudKit development environment, when your app creates a record, CloudKit automatically creates the record type, if it doesn’t exist. With that, if you ever persist (at least) an instance for each of your SwiftData type, and the instance is pushed to CloudKit, the CloudKit schema will have the record type for you. Otherwise, the record type will be missed. initializeCloudKitSchema(options:) works by creating a set of representative records, uploading them to CloudKit, and removing them. This may help if it is indeed that no instance of your new SwiftData type has ever been uploaded to CloudKit. Note that even initializeCloudKitSchema(options:) can miss something, and that is why I called out the following: After running the target, use CloudKit Console to ensure each Core Data entity and attribute has a CloudKit counterpart. See Reading CloudKit Records for Core Data for the mapping rules. The documentation discusses how NSPersistentCloudKitContainer maps a Core Data model to a CloudKi
Sep ’25
Reply to v1/appPriceSchedules 409
I'm having the same issue, any updates on this? data: { type: subscriptionPromotionalOffers, attributes: { name: Tier2 50% off, offerCode: appoffTest01, duration: ONE_WEEK, offerMode: PAY_AS_YOU_GO, numberOfPeriods: 1 }, relationships: { subscription: { data: { type: subscriptions, id: 6751863227 } }, prices: { data: [ { type: subscriptionPromotionalOfferPrices, id: 1701cff0-c38d-4460-9845-43601292edbd } ] } } }, included: [ { type: subscriptionPromotionalOfferPrices, id: 1701cff0-c38d-4460-9845-43601292edbd, relationships: { subscriptionPricePoint: { data: { type: subscriptionPricePoints, id: eyJzIjoiNjc1MTg2MzIyNyIsInQiOiJBRkciLCJwIjoiMTAxMzIifQ } } } } ] } errors: [ { id: 659be9c5-3a02-4a78-bf51-e40bf5c96138, status: 409, code: ENTITY_ERROR.INCLUDED.INVALID_ID, title: The provided entity id is invalid, detail: The provided included entity id '1701cff0-c38d-4460-9845-43601292edbd' has invalid format, source: { pointer: /included/0/id } } ] }
Sep ’25
Reply to SwiftData - Cloudkit stopped syncing
You mentioned that the new model isn't listed as an indes. Does that mean your new model type does not show up as part of the CloudKit schema (and hence CloudKit Console sees no changes between your development and production schemas )? If yes, that will be the culprit – The framework will stop synchronizing data when detecting that the CloudKit schema doesn't match your SwiftData models. When changing your SwiftData model types, be sure that the change is pushed to the CloudKit development environment, which is eventually promoted to the production environment. How to push your change to the CloudKit development environment is described in Initialize the CloudKit development schema. The details in Create the CloudKit schema may help as well. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Sep ’25
Charts SectorMark causing app to crash
Anytime I have 1 item, then add another, the app crashes with the following error: Swift/IntegerTypes.swift:8835: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN I'm not working with Int values though, so I'm not sure why this is happening. It's also not point me towards any specific line. I've printed out all of the values being used for the chart and none of them are showing as infinite or NaN. The data being used is created in a View. @State private var pieChartData: [PieChartDataPoint] = [] Then in the onAppear and onChange its gets loaded using the following function: func getPieChartDataPoints() -> [PieChartDataPoint] { self.map({ PieChartDataPoint(label: $0.name, value: $0.monthlyAmount()) }) } That's an extension on a SwiftData model type I have called Recurring. @Model final class Recurring { var id = UUID() enum Kind: String, CaseIterable, Codable { case income = Income case bill = Bill func plural() -> String { switch self { case .income: Inc
1
0
126
Aug ’25
AppIntent, StartWorkoutIntent, and Siri
I'm a bit confused as to what we're supposed to be doing to support starting a workout using Siri in iOS/watchOS 26. On one hand, I see a big push to move towards App Intents and shortcuts rather than SiriKit. On the other hand, I see that some of the things I would expect to work with App Intents well... don't work. BUT - I'm also not sure it isn't just developer error on my part. Here are some assertions that I'm hoping someone more skilled and knowledgable can correct me on: Currently the StartWorkoutIntent only serves the Action button on the Watch Ultra. It cannot be used to register Shortcuts, nor does Siri respond to it. I can use objects inherited from AppIntent to create shortcuts, but this requires an additional permission to run a shortcut if a user starts a workout with Siri. AppIntent shortcuts requires the user to say Start a workout in - if the user leaves out the in part, Siri will not prompt the user to select my app. If I want to allow the user to simply say Start a Workout and ha
1
0
356
Aug ’25
Reply to AppIntent, StartWorkoutIntent, and Siri
BUT - I'm also not sure it isn't just developer error on my part. As top-level advice, take a look at the Trails sample app, as it does implement the App Intents StartWorkoutIntent and related APIs, so that you have a reference implementation to consult for what is possible on iOS and watchOS. Currently the StartWorkoutIntent only serves the Action button on the Watch Ultra. It cannot be used to register Shortcuts, nor does Siri respond to it. StartWorkoutIntent is available on iOS, and the sample above demonstrates that. As to using it with Siri, the sample is configured with that intent as an App Shortcut, so it is available through Siri. I can use objects inherited from AppIntent to create shortcuts, but this requires an additional permission to run a shortcut if a user starts a workout with Siri. Depending on a variety of factors controller by the system, a customer can sometimes be prompted for permission to run an intent. That is broadly true, and not specific to anything about workout intents
Aug ’25
SwiftData Inheritance Query Specialized Model
Hi, I am currently experiencing some trouble when using parent model property in a predicate of a child model. I have an Item class that define parent-child relationship: @Model class Item { var timestamp: Date @Relationship(inverse: Item.children) var parent: Item? var children: [Item] init(parent: Item? = nil, children: [Item] = [], timestamp: Date = .now) { self.parent = parent self.children = children self.timestamp = timestamp } } I subclass this model like that: @available(iOS 26, *) @Model final class CollectionItem: Item { /* ... */ } When i make a Query in my View like that the system crashes: @Query( filter: #Predicate { $0.parent == nil }, sort: CollectionItem.name, ) private var collections: [CollectionItem] CrashReportError: Fatal Error in DataUtilities.swift AppName crashed due to fatalError in DataUtilities.swift at line 85. Couldn't find CollectionItem.)> on CollectionItem with fields [SwiftData.Schema.PropertyMetadata(name: name, keypath: CollectionItem., defaultValue: ni
9
0
369
Aug ’25
Reply to False positive 'Deceptive Website' warning for personal domain
It's probably related to whatever you are doing with adguard and vaultwarden. I don't know what any of that is, but when I search for your domain, it shows up on a couple of Github domain lists. I also don't know what those domain lists are for. But if you're going to play around with anything even remotely related to security, you should do that on a burner site. Otherwise, you effectively turn your site into a burner site. There is no differentiation on the internet between legal/illegal, safe or malicious. It's the internet. It's all illegal and malicious, unless proven otherwise. Google and others work hard to hide that from regular folks. But if you fall through the cracks, even by accident, it's your problem to solve. Nobody's going to help. This is a developer support forum. It's a place for questions about SwiftUI, APIs, NSURLSession, etc. You can ask anything you want, but if you're asking about something that isn't developer related, you probably won't get any answer. I can tell you that there is no
Topic: Safari & Web SubTopic: General Tags:
Aug ’25
Reply to SwiftData & CloudKit: Arrays of Codable Structs Causing NSKeyedUnarchiveFromData Error
I switch to using Data with Transient computed property and it still is showing the same error logged to the console: import SwiftData @Model final class ProtocolMedication { var uuid: UUID = UUID() var createdAt: Date = Date() var frequency: SchedulingFrequency = SchedulingFrequency.atRegularIntervals var interval: SchedulingInterval = SchedulingInterval(days: 1) var startDate: Date = Date() var timesData: Data? var dayOfWeekSelection: DayOfWeekSelection = DayOfWeekSelection(days: [1]) var injectionRotationConfig: InjectionRotationConfig = InjectionRotationConfig() var medicationConcentration: MedicationConcentration = MedicationConcentration(value: nil, unit: nil) var medication: Medication? @Relationship(deleteRule: .cascade, inverse: ScheduledDose.protocolMed) var _scheduledDoses: [ScheduledDose]? @Relationship(deleteRule: .cascade, inverse: DoseLog.protocolMed) var _doseLogs: [DoseLog]? @Transient var times: [SchedulingTime] { get { guard let data = timesData else { return [] }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’25
Reply to SwiftData & CloudKit: Arrays of Codable Structs Causing NSKeyedUnarchiveFromData Error
Do you have a feedback report yet? If not, I’d suggest that you file one and share your report ID here. For a workaround, you might consider making SchedulingTime a SwiftData model, if that is appropriate, and relating it to ProtocolMedication with a too-many relationship. You can also consider using Data directly for persistence, and providing a transient (@Transient) property for the access to the struct array (only) in memory. A transient property can't be used in a query though. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’25
SwiftUI TextField input is super laggy for SwiftData object
have a SwiftUI View where I can edit financial transaction information. The data is stored in SwiftData. If I enter a TextField element and start typing, it is super laggy and there are hangs of 1-2 seconds between each input (identical behaviour if debugger is detached). On the same view I have another TextField that is just attached to a @State variable of that view and TextField updates of that value work flawlessly. So somehow the hangs must be related to my SwiftData object but I cannot figure out why. This used to work fine until a few months ago and then I could see the performance degrading. I have noticed that when I use a placeholder variable like @State private var transactionSubject: String = and link that to the TextField, the performance is back to normal. I am then using .onSubmit { self.transaction.subject = self.transactionSubject } to update the value in the end but this again causes a 1 s hang. :/ Below the original code sample with some unnecessary stuff removed: struct
Replies
2
Boosts
0
Views
194
Activity
Sep ’25
SwiftData - Cloudkit stopped syncing
I have an app that from day 1 has used Swiftdata and successfully sync'd across devices with Cloudkit. I have added models to the data in the past and deployed the schema and it continued to sync across devices. Sometime I think in June.2025 I added a new model and built out the UI to display and manage it. I pushed a version to Test Flight (twice over a matter of 2 versions and a couple of weeks) and created objects in the new model in Test Flight versions of the app which should push the info to Cloudkit to update the schema. When I go to deploy the schema though there are no changes. I confirmed in the app that Cloudkit is selected and it's point to the correct container. And when I look in Cloudkit the new model isn't listed as an indes. I've pushed deploy schema changes anyway (more than once) and now the app isn't sync-ing across devices at all (even the pre-existing models aren't sync-ing across devices). I even submitted the first updated version to the app store and it was approved and relea
Replies
3
Boosts
0
Views
251
Activity
Sep ’25
Reply to SwiftData - Cloudkit stopped syncing
In CloudKit development environment, when your app creates a record, CloudKit automatically creates the record type, if it doesn’t exist. With that, if you ever persist (at least) an instance for each of your SwiftData type, and the instance is pushed to CloudKit, the CloudKit schema will have the record type for you. Otherwise, the record type will be missed. initializeCloudKitSchema(options:) works by creating a set of representative records, uploading them to CloudKit, and removing them. This may help if it is indeed that no instance of your new SwiftData type has ever been uploaded to CloudKit. Note that even initializeCloudKitSchema(options:) can miss something, and that is why I called out the following: After running the target, use CloudKit Console to ensure each Core Data entity and attribute has a CloudKit counterpart. See Reading CloudKit Records for Core Data for the mapping rules. The documentation discusses how NSPersistentCloudKitContainer maps a Core Data model to a CloudKi
Replies
Boosts
Views
Activity
Sep ’25
Reply to v1/appPriceSchedules 409
I'm having the same issue, any updates on this? data: { type: subscriptionPromotionalOffers, attributes: { name: Tier2 50% off, offerCode: appoffTest01, duration: ONE_WEEK, offerMode: PAY_AS_YOU_GO, numberOfPeriods: 1 }, relationships: { subscription: { data: { type: subscriptions, id: 6751863227 } }, prices: { data: [ { type: subscriptionPromotionalOfferPrices, id: 1701cff0-c38d-4460-9845-43601292edbd } ] } } }, included: [ { type: subscriptionPromotionalOfferPrices, id: 1701cff0-c38d-4460-9845-43601292edbd, relationships: { subscriptionPricePoint: { data: { type: subscriptionPricePoints, id: eyJzIjoiNjc1MTg2MzIyNyIsInQiOiJBRkciLCJwIjoiMTAxMzIifQ } } } } ] } errors: [ { id: 659be9c5-3a02-4a78-bf51-e40bf5c96138, status: 409, code: ENTITY_ERROR.INCLUDED.INVALID_ID, title: The provided entity id is invalid, detail: The provided included entity id '1701cff0-c38d-4460-9845-43601292edbd' has invalid format, source: { pointer: /included/0/id } } ] }
Replies
Boosts
Views
Activity
Sep ’25
The occulution relationship of virtual content and real object
I am using Entity of RealityKit to display virtual content, however I find that sometimes the real object in front of the virtual content can not occulude the virtual content. For example, I place an Entity in a room, but when I walk into another room, I can still see the Entity through the wall. I wonder how should I fix the problem. Thank you!
Replies
2
Boosts
0
Views
383
Activity
Mar ’25
Reply to SwiftData - Cloudkit stopped syncing
You mentioned that the new model isn't listed as an indes. Does that mean your new model type does not show up as part of the CloudKit schema (and hence CloudKit Console sees no changes between your development and production schemas )? If yes, that will be the culprit – The framework will stop synchronizing data when detecting that the CloudKit schema doesn't match your SwiftData models. When changing your SwiftData model types, be sure that the change is pushed to the CloudKit development environment, which is eventually promoted to the production environment. How to push your change to the CloudKit development environment is described in Initialize the CloudKit development schema. The details in Create the CloudKit schema may help as well. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Sep ’25
Charts SectorMark causing app to crash
Anytime I have 1 item, then add another, the app crashes with the following error: Swift/IntegerTypes.swift:8835: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN I'm not working with Int values though, so I'm not sure why this is happening. It's also not point me towards any specific line. I've printed out all of the values being used for the chart and none of them are showing as infinite or NaN. The data being used is created in a View. @State private var pieChartData: [PieChartDataPoint] = [] Then in the onAppear and onChange its gets loaded using the following function: func getPieChartDataPoints() -> [PieChartDataPoint] { self.map({ PieChartDataPoint(label: $0.name, value: $0.monthlyAmount()) }) } That's an extension on a SwiftData model type I have called Recurring. @Model final class Recurring { var id = UUID() enum Kind: String, CaseIterable, Codable { case income = Income case bill = Bill func plural() -> String { switch self { case .income: Inc
Replies
1
Boosts
0
Views
126
Activity
Aug ’25
AppIntent, StartWorkoutIntent, and Siri
I'm a bit confused as to what we're supposed to be doing to support starting a workout using Siri in iOS/watchOS 26. On one hand, I see a big push to move towards App Intents and shortcuts rather than SiriKit. On the other hand, I see that some of the things I would expect to work with App Intents well... don't work. BUT - I'm also not sure it isn't just developer error on my part. Here are some assertions that I'm hoping someone more skilled and knowledgable can correct me on: Currently the StartWorkoutIntent only serves the Action button on the Watch Ultra. It cannot be used to register Shortcuts, nor does Siri respond to it. I can use objects inherited from AppIntent to create shortcuts, but this requires an additional permission to run a shortcut if a user starts a workout with Siri. AppIntent shortcuts requires the user to say Start a workout in - if the user leaves out the in part, Siri will not prompt the user to select my app. If I want to allow the user to simply say Start a Workout and ha
Replies
1
Boosts
0
Views
356
Activity
Aug ’25
Reply to AppIntent, StartWorkoutIntent, and Siri
BUT - I'm also not sure it isn't just developer error on my part. As top-level advice, take a look at the Trails sample app, as it does implement the App Intents StartWorkoutIntent and related APIs, so that you have a reference implementation to consult for what is possible on iOS and watchOS. Currently the StartWorkoutIntent only serves the Action button on the Watch Ultra. It cannot be used to register Shortcuts, nor does Siri respond to it. StartWorkoutIntent is available on iOS, and the sample above demonstrates that. As to using it with Siri, the sample is configured with that intent as an App Shortcut, so it is available through Siri. I can use objects inherited from AppIntent to create shortcuts, but this requires an additional permission to run a shortcut if a user starts a workout with Siri. Depending on a variety of factors controller by the system, a customer can sometimes be prompted for permission to run an intent. That is broadly true, and not specific to anything about workout intents
Replies
Boosts
Views
Activity
Aug ’25
SwiftData Inheritance Query Specialized Model
Hi, I am currently experiencing some trouble when using parent model property in a predicate of a child model. I have an Item class that define parent-child relationship: @Model class Item { var timestamp: Date @Relationship(inverse: Item.children) var parent: Item? var children: [Item] init(parent: Item? = nil, children: [Item] = [], timestamp: Date = .now) { self.parent = parent self.children = children self.timestamp = timestamp } } I subclass this model like that: @available(iOS 26, *) @Model final class CollectionItem: Item { /* ... */ } When i make a Query in my View like that the system crashes: @Query( filter: #Predicate { $0.parent == nil }, sort: CollectionItem.name, ) private var collections: [CollectionItem] CrashReportError: Fatal Error in DataUtilities.swift AppName crashed due to fatalError in DataUtilities.swift at line 85. Couldn't find CollectionItem.)> on CollectionItem with fields [SwiftData.Schema.PropertyMetadata(name: name, keypath: CollectionItem., defaultValue: ni
Replies
9
Boosts
0
Views
369
Activity
Aug ’25
Reply to SwiftData Inheritance Query Specialized Model
FB19957253 (Crash on Hierarchical List children access from SwiftData inherited model) Again, thank you so much! I hope I gave enough informations, feel free to ask if I can do anything.
Replies
Boosts
Views
Activity
Aug ’25
Reply to SwiftData Inheritance Query Specialized Model
That's most likely a bug happening when creating a hierarchical list using List(… children) + SwiftData. Would you mind to file a feedback report for us with your reproducible case, and share your report ID here? Thanks. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Aug ’25
Reply to False positive 'Deceptive Website' warning for personal domain
It's probably related to whatever you are doing with adguard and vaultwarden. I don't know what any of that is, but when I search for your domain, it shows up on a couple of Github domain lists. I also don't know what those domain lists are for. But if you're going to play around with anything even remotely related to security, you should do that on a burner site. Otherwise, you effectively turn your site into a burner site. There is no differentiation on the internet between legal/illegal, safe or malicious. It's the internet. It's all illegal and malicious, unless proven otherwise. Google and others work hard to hide that from regular folks. But if you fall through the cracks, even by accident, it's your problem to solve. Nobody's going to help. This is a developer support forum. It's a place for questions about SwiftUI, APIs, NSURLSession, etc. You can ask anything you want, but if you're asking about something that isn't developer related, you probably won't get any answer. I can tell you that there is no
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’25