Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftData on iOS 18 extreme memory use
Yeah, what you described points to a SwiftData memory management issue on iOS 18. Thanks for filing the feedback reports. Before the issue is fixed on the framework side, I am trying to explore a workaround. Did you even try the following, or can the following, if working, be an option in your case? Replacing the image data attribute (Item.image) with a relationship, which hopefully avoids loading the whole image when querying items. Using the other way, like fetchCount(_:), to retrieve the count of items. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’24
Receiver class org.openqa.selenium.safari.SafariDriverService$Builder does not define or inherit an implementation of the resolved method 'abstract com.google.common.collect.ImmutableList createArgs()' of abstract class org.openqa.selenium.remote.ser
Hello, I am new to safari, and the safari web driver and I am trying to write a java program using selenium to open a web page.... import org.openqa.selenium.WebDriver; import org.openqa.selenium.safari.SafariDriver; // import org.openqa.selenium.Saf // I have not imported the following // import org.openqa.selenium.safari.SafariDriver; // because this does not provide me with the SafariDriver. public class Test_SafariDemo { // the purpose of this class is to test the Safari driver // Written by Michael John Little // Based on a Java program from... // https://www.browserstack.com/guide/run-selenium-tests-on-safari-using-safaridriver public static void main(String[] args) { // lets Instantiate a Safari driver class WebDriver drvr =null; try { drvr = new SafariDriver(); } catch (Exception e) { System.out.print(e); } // lets Launch the Google website drvr.navigate().to(http://www.google.com/); // lets click on the search box and send a value drvr.findElement(By.id(lst-ib)).sendKeys(BrowserStack); // click the s
1
0
1.4k
Feb ’23
Xcode 15 has problem of generated Swift NSObject headers: Property type 'NSInteger' (aka 'long') is incompatible with type 'NSUInteger' (aka 'unsigned long') inherited from 'NSObject'
The generated Obj-C header for Swift is called @property (nonatomic, readonly) NSInteger hash; However, it caused a compiler error: Property type 'NSInteger' (aka 'long') is incompatible with type 'NSUInteger' (aka 'unsigned long') inherited from 'NSObject' Version 15.0 beta (15A5160n)
7
0
1.7k
Jun ’23
SwiftData Models and SortDesc. Only Work in One Swift File
Hey everyone, I found a possible SwiftData Release-only issue with nested sort descriptors on an optional relationship. In a minimal repro, sorting a @Query by a nested optional relationship key path like: SortDescriptor(InvestigationPhotoAsset.imageAnalysis?.overallAestheticsScore, order: .reverse) works in Debug, but crashes at runtime in Release. The surprising part is that the crash depends on file layout: if the active SwiftData models and the sort logic are kept in the same Swift file, the app works if the same models are split into separate files, the Release build crashes, 'Debug' will also work The repro was reduced to just two SwiftData models: InvestigationPhotoAsset InvestigationImageAnalysis So this looks less like an app-modeling issue and more like a SwiftData/compiler/codegen issue related to nested sort metadata in optimized builds. If useful, I can also give you a slightly more formal version with a title and code snippet block. Please ch
4
0
270
3w
SwiftData delete doesn't work
I'm using SwiftData to save title and images. When I delete the model, the fetched model count reduces. But in the settings - storage - myApp, the document and data does not change. I deleted all the models but its like 9GB left. I followed the SwiftData example app provided by Apple as much as possible. I tried isAutosaveEnabled = false and put save() to every delete functions. deleteRule = .cascade
0
0
615
Mar ’24
ForEach and SwiftData Model
Hello World ! I have an issue with a ForEach loop and a SwiftData Model Here is the code : import Foundation import SwiftData @Model final class Todo { var id: UUID var content: String var isDone: Bool var isImportant: Bool var sortValue: Int init(content: String, isDone: Bool, isImportant: Bool) { self.id = UUID() self.content = content self.isDone = isDone self.isImportant = isImportant if isImportant{ self.sortValue = 0 } else { self.sortValue = 1 } } } final class Tag { var id: UUID var content: String init(content: String) { self.id = UUID() self.content = content } } and the content view : import SwiftUI import SwiftData struct AddTodoView: View { @Environment(.modelContext) private var modelContext @Environment(.dismiss) var dismiss @Query private var tags: [Tag] @State private var selectedTag: UUID @State private var content: String = @State private var isImportant: Bool = false @State private var showAlert: Bool = false @State private var showAchivement: Bool = false var b
1
0
1.4k
Nov ’23
Reply to SwiftData SortDescriptor Limitation...
Could be the same issue. I tried reporting this directly to Apple with a request for Technical Assistance because I hadn't seen any other reports of this behavior. I had developed a SwiftData app that used CloudKit and therefore required all model relationships to be treated as optional. I was sorting an object using a relationship's title field (which was clearly optional) and this worked fine in all simulator and Xcode downloads with no issues. I didn't run into it until I tried using TestFlight to get some beta feedback and the app immediately crashed and the feedback was sparse so I took several months to finally track down what was causing it. I would certainly like to see this fixed because it creates limitations that only surface very late ih the app dev process which is very frustrating. If it shouldn't ever work then it should also crash in the simulator and any Xcode downloads IMHO.
Aug ’25
Can a private database entity have a relationship to a public database entity?
I’m using NSPersistentCloudKitContainer and I’m utilising the public database and also the user’s private database. For example I have an entity called Category which has a many-to-many relationship to an entity called NewsArticle. So the NewsArticles exist in the public database for the user to browse, but he can add them to a category which will live in his private database. So that’s my question, is it possible for an entity which exists a in the private database to have a relationship to another entity in a public database?
1
0
977
May ’23
SwiftData CloudKit sync broken on iOS 26
Hi everyone, I’m running into a breaking issue with SwiftData automatic CloudKit syncing on iOS 26, and I'm trying to determine if this is a known regression or a new configuration requirement I missed. The Setup: My setup is extremely standard; I am using the default configuration exactly as described in Apple's documentation here: https://developer.apple.com/documentation/swiftdata/syncing-model-data-across-a-persons-devices The schema is very simple: A single @Model class. No relationships. The Issue: Prior to iOS 26, this exact app was successfully syncing data between devices and to iCloud without issues. Immediately after the iOS 26 update, syncing stopped completely. I haven't changed any code, but when I check the CloudKit Console, I am seeing some BAD_REQUEST errors during sync attempts. Since I am using the default SwiftData sync (and not manual CKRecord handling), I’m not sure how my client code could be triggering a bad request unless the schema requirements hav
1
0
295
Jan ’26
SwiftData Upsert
How do I get Upsert to work in SwiftData? I have a model: @Model class Address: Identifiable { @Attribute(.unique) var id: Int = 0 var number: String = var street: String? var city: String? } When I insert a duplicate record with the same data attributes (specifically overlapping id) and execute modelContext.save() I receive a EXC_BREAKPOINT. let addressA = Address(id: 1, number: 2300, street: E Main St, city: Small Town ); modelContext.insert(addressA) try? modelContext.save() let addressAv2 = Address(id: 1, number: 2300, street: E Main St, city: Small Town ); modelContext.insert(addressAv2) try? modelContext.save() // This fails Is there a better way to handle updates?
1
0
953
Nov ’23
Migrating a swiftData project to CloudKit to implement iCloudSync.
My project is using swiftData and I want to implement iCloud sync in it. Now, my data base doesnt have any optional attributes or relationships and CloudKit wants them to be optional. So, rather than editing all code with unwrapping code for the optionals, how can I provide a bridge that does so in the last stage of actually saving to the store? Sort of, capture it in a proxy object before writing and after reading from the store. Is there a neat way that can save a lot of debugging? I have code snippets from chat gpt and they are hard to debug. This is my first project in swiftUI. Thanks. Neerav
3
0
190
May ’25
SwiftData app storage
I created an app using SwiftData to store titles, dates, and images. When creating and deleting data models repeatedly, the app's storage space should remains the same, but for me it steadily accumulate so now its 5GB in the app's settings despite having no data. Why is this happening?
1
0
714
Mar ’24
CKSyncEngine with SwiftData
I have been working on a toy app to learn CKSyncEngine. I'm using SwiftData as local storage with Cloudkit disabled, and use the CKSyncEngine to handle everything with full control. I've gotten everything to work except for one thing! Updating the UI from the SyncEngine. I have tested this outside the syncEngine and using @ModelActor and performing changes in a detached Task in the background updates the UI perfectly. However, I've made my class conforming to the engine a model-actor but it does not update the UI when I save from the actor's ctx. If I go back to a view in the navigation and return the data is updated, but not when it is modified. I'm at my wit's end and I think it must be the way CKSyncEngine updates are triggered in the background. Any suggestions to the possible root cause?
0
0
718
Jan ’24
Reply to SwiftData on iOS 18 extreme memory use
Yeah, what you described points to a SwiftData memory management issue on iOS 18. Thanks for filing the feedback reports. Before the issue is fixed on the framework side, I am trying to explore a workaround. Did you even try the following, or can the following, if working, be an option in your case? Replacing the image data attribute (Item.image) with a relationship, which hopefully avoids loading the whole image when querying items. Using the other way, like fetchCount(_:), to retrieve the count of items. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’24
Receiver class org.openqa.selenium.safari.SafariDriverService$Builder does not define or inherit an implementation of the resolved method 'abstract com.google.common.collect.ImmutableList createArgs()' of abstract class org.openqa.selenium.remote.ser
Hello, I am new to safari, and the safari web driver and I am trying to write a java program using selenium to open a web page.... import org.openqa.selenium.WebDriver; import org.openqa.selenium.safari.SafariDriver; // import org.openqa.selenium.Saf // I have not imported the following // import org.openqa.selenium.safari.SafariDriver; // because this does not provide me with the SafariDriver. public class Test_SafariDemo { // the purpose of this class is to test the Safari driver // Written by Michael John Little // Based on a Java program from... // https://www.browserstack.com/guide/run-selenium-tests-on-safari-using-safaridriver public static void main(String[] args) { // lets Instantiate a Safari driver class WebDriver drvr =null; try { drvr = new SafariDriver(); } catch (Exception e) { System.out.print(e); } // lets Launch the Google website drvr.navigate().to(http://www.google.com/); // lets click on the search box and send a value drvr.findElement(By.id(lst-ib)).sendKeys(BrowserStack); // click the s
Replies
1
Boosts
0
Views
1.4k
Activity
Feb ’23
Xcode 15 has problem of generated Swift NSObject headers: Property type 'NSInteger' (aka 'long') is incompatible with type 'NSUInteger' (aka 'unsigned long') inherited from 'NSObject'
The generated Obj-C header for Swift is called @property (nonatomic, readonly) NSInteger hash; However, it caused a compiler error: Property type 'NSInteger' (aka 'long') is incompatible with type 'NSUInteger' (aka 'unsigned long') inherited from 'NSObject' Version 15.0 beta (15A5160n)
Replies
7
Boosts
0
Views
1.7k
Activity
Jun ’23
Custom backing store for SwiftData?
I’m working on an app where I have some sensitive data that I want to encrypt when persisting. It looks like SwiftData has a BackingData protocol but it mentions it's for in-memory only. Is there a way to provide a custom storage for SwiftData so that I can encrypt the data before saving?
Replies
0
Boosts
0
Views
890
Activity
Jul ’23
SwiftData Models and SortDesc. Only Work in One Swift File
Hey everyone, I found a possible SwiftData Release-only issue with nested sort descriptors on an optional relationship. In a minimal repro, sorting a @Query by a nested optional relationship key path like: SortDescriptor(InvestigationPhotoAsset.imageAnalysis?.overallAestheticsScore, order: .reverse) works in Debug, but crashes at runtime in Release. The surprising part is that the crash depends on file layout: if the active SwiftData models and the sort logic are kept in the same Swift file, the app works if the same models are split into separate files, the Release build crashes, 'Debug' will also work The repro was reduced to just two SwiftData models: InvestigationPhotoAsset InvestigationImageAnalysis So this looks less like an app-modeling issue and more like a SwiftData/compiler/codegen issue related to nested sort metadata in optimized builds. If useful, I can also give you a slightly more formal version with a title and code snippet block. Please ch
Replies
4
Boosts
0
Views
270
Activity
3w
SwiftData delete doesn't work
I'm using SwiftData to save title and images. When I delete the model, the fetched model count reduces. But in the settings - storage - myApp, the document and data does not change. I deleted all the models but its like 9GB left. I followed the SwiftData example app provided by Apple as much as possible. I tried isAutosaveEnabled = false and put save() to every delete functions. deleteRule = .cascade
Replies
0
Boosts
0
Views
615
Activity
Mar ’24
ForEach and SwiftData Model
Hello World ! I have an issue with a ForEach loop and a SwiftData Model Here is the code : import Foundation import SwiftData @Model final class Todo { var id: UUID var content: String var isDone: Bool var isImportant: Bool var sortValue: Int init(content: String, isDone: Bool, isImportant: Bool) { self.id = UUID() self.content = content self.isDone = isDone self.isImportant = isImportant if isImportant{ self.sortValue = 0 } else { self.sortValue = 1 } } } final class Tag { var id: UUID var content: String init(content: String) { self.id = UUID() self.content = content } } and the content view : import SwiftUI import SwiftData struct AddTodoView: View { @Environment(.modelContext) private var modelContext @Environment(.dismiss) var dismiss @Query private var tags: [Tag] @State private var selectedTag: UUID @State private var content: String = @State private var isImportant: Bool = false @State private var showAlert: Bool = false @State private var showAchivement: Bool = false var b
Replies
1
Boosts
0
Views
1.4k
Activity
Nov ’23
Reply to SwiftData SortDescriptor Limitation...
Could be the same issue. I tried reporting this directly to Apple with a request for Technical Assistance because I hadn't seen any other reports of this behavior. I had developed a SwiftData app that used CloudKit and therefore required all model relationships to be treated as optional. I was sorting an object using a relationship's title field (which was clearly optional) and this worked fine in all simulator and Xcode downloads with no issues. I didn't run into it until I tried using TestFlight to get some beta feedback and the app immediately crashed and the feedback was sparse so I took several months to finally track down what was causing it. I would certainly like to see this fixed because it creates limitations that only surface very late ih the app dev process which is very frustrating. If it shouldn't ever work then it should also crash in the simulator and any Xcode downloads IMHO.
Replies
Boosts
Views
Activity
Aug ’25
Can a private database entity have a relationship to a public database entity?
I’m using NSPersistentCloudKitContainer and I’m utilising the public database and also the user’s private database. For example I have an entity called Category which has a many-to-many relationship to an entity called NewsArticle. So the NewsArticles exist in the public database for the user to browse, but he can add them to a category which will live in his private database. So that’s my question, is it possible for an entity which exists a in the private database to have a relationship to another entity in a public database?
Replies
1
Boosts
0
Views
977
Activity
May ’23
SwiftData CloudKit sync broken on iOS 26
Hi everyone, I’m running into a breaking issue with SwiftData automatic CloudKit syncing on iOS 26, and I'm trying to determine if this is a known regression or a new configuration requirement I missed. The Setup: My setup is extremely standard; I am using the default configuration exactly as described in Apple's documentation here: https://developer.apple.com/documentation/swiftdata/syncing-model-data-across-a-persons-devices The schema is very simple: A single @Model class. No relationships. The Issue: Prior to iOS 26, this exact app was successfully syncing data between devices and to iCloud without issues. Immediately after the iOS 26 update, syncing stopped completely. I haven't changed any code, but when I check the CloudKit Console, I am seeing some BAD_REQUEST errors during sync attempts. Since I am using the default SwiftData sync (and not manual CKRecord handling), I’m not sure how my client code could be triggering a bad request unless the schema requirements hav
Replies
1
Boosts
0
Views
295
Activity
Jan ’26
SwiftData Upsert
How do I get Upsert to work in SwiftData? I have a model: @Model class Address: Identifiable { @Attribute(.unique) var id: Int = 0 var number: String = var street: String? var city: String? } When I insert a duplicate record with the same data attributes (specifically overlapping id) and execute modelContext.save() I receive a EXC_BREAKPOINT. let addressA = Address(id: 1, number: 2300, street: E Main St, city: Small Town ); modelContext.insert(addressA) try? modelContext.save() let addressAv2 = Address(id: 1, number: 2300, street: E Main St, city: Small Town ); modelContext.insert(addressAv2) try? modelContext.save() // This fails Is there a better way to handle updates?
Replies
1
Boosts
0
Views
953
Activity
Nov ’23
Migrating a swiftData project to CloudKit to implement iCloudSync.
My project is using swiftData and I want to implement iCloud sync in it. Now, my data base doesnt have any optional attributes or relationships and CloudKit wants them to be optional. So, rather than editing all code with unwrapping code for the optionals, how can I provide a bridge that does so in the last stage of actually saving to the store? Sort of, capture it in a proxy object before writing and after reading from the store. Is there a neat way that can save a lot of debugging? I have code snippets from chat gpt and they are hard to debug. This is my first project in swiftUI. Thanks. Neerav
Replies
3
Boosts
0
Views
190
Activity
May ’25
SwiftData app storage
I created an app using SwiftData to store titles, dates, and images. When creating and deleting data models repeatedly, the app's storage space should remains the same, but for me it steadily accumulate so now its 5GB in the app's settings despite having no data. Why is this happening?
Replies
1
Boosts
0
Views
714
Activity
Mar ’24
What should I do if I want to mimic real-world occlusion relationships
I have a problem. In AR mode, objects or people in the real environment cannot dynamically block the virtual 3D model. What should I do if I want to mimic real-world occlusion relationships?
Replies
1
Boosts
0
Views
336
Activity
Nov ’24
CKSyncEngine with SwiftData
I have been working on a toy app to learn CKSyncEngine. I'm using SwiftData as local storage with Cloudkit disabled, and use the CKSyncEngine to handle everything with full control. I've gotten everything to work except for one thing! Updating the UI from the SyncEngine. I have tested this outside the syncEngine and using @ModelActor and performing changes in a detached Task in the background updates the UI perfectly. However, I've made my class conforming to the engine a model-actor but it does not update the UI when I save from the actor's ctx. If I go back to a view in the navigation and return the data is updated, but not when it is modified. I'm at my wit's end and I think it must be the way CKSyncEngine updates are triggered in the background. Any suggestions to the possible root cause?
Replies
0
Boosts
0
Views
718
Activity
Jan ’24