Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to iOS 16.3 in Simulator
Definitely an issue in xCode 16.3 as it applies to inherited properties and the simulators. I can't diagnose why it's happening, but there are cases where the value shown in the debugger is not what it should be and that causes code to fail. What's crazy is that looking in the debugger at self.inheritedProperty and then expanding self and drilling down to inheritedProperty, the values do not match. The value on the self node is correct. The issue does not occur on a real device and Xcode 16.0 is still solid as it applies to simulators. Personally, I will be avoiding xCode 16.3 until Apple issues an update that addresses a fix for this.
Apr ’25
Stopping certain data models from syncing to cloudkit
Hi all, I am using SwiftData and cloudkit and I am having an extremely persistent bug. I am building an education section on a app that's populated with lessons via a local JSON file. I don't need this lesson data to sync to cloudkit as the lessons are static, just need them imported into swiftdata so I've tried to use the modelcontainer like this: static func createSharedModelContainer() -> ModelContainer { // --- Define Model Groups --- let localOnlyModels: [any PersistentModel.Type] = [ Lesson.self, MiniLesson.self, Quiz.self, Question.self ] let cloudKitSyncModels: [any PersistentModel.Type] = [ User.self, DailyTip.self, UserSubscription.self, UserEducationProgress.self // User progress syncs ] However, what happens is that I still get Lesson and MiniLesson record types on cloudkit and for some reason as well, whenever I update the data models or delete and reinstall the app on simulator, the lessons duplicate (what seems to happen is that a set of lessons comes from the JSON file as
0
0
113
Apr ’25
Reply to How to import large data from Server and save it to Swift Data
Do you know how much data is expected to be downloaded? If so, you could ensure the view doesn't update until the right amount of data is received and stored. If you don't know the quantity of data, you could add a Bool and toggle it when the data loading starts, then toggle it when the data has finished loading, so the View is only refreshed when the last of the data is stored. Another way would be to disable the UI so the user can't interact with it until the data has finished loading. The UI would update in the background, but the user wouldn't experience a slow UI as they can't interact with it anyway. You could put a partially-transparent View with a ProgressView in it at the top of a ZStack (which would be at the bottom of the ZStack in the code...) and hide it when you're done. I'll show you how I do it below. There's a few ways of doing it, but I don't think there's a built-in way to achieve this. But then, I'm not a genius on SwiftData, so... Using a blocking view: @State private var loading
Apr ’25
Open child windows for a document in a document based SwiftData app
In a document based SwiftData app for macOS, how do you go about opening a (modal) child window connected to the ModelContainer of the currently open document? Using .sheet() does not really result in a good UX, as the appearing view lacks the standard window toolbar. Using a separate WindowGroup with an argument would achieve the desired UX. However, as WindowGroup arguments need to be Hashable and Codable, there is no way to pass a ModelContainer or a ModelContext there: WindowGroup(id: myWindowGroup, for: MyWindowGroupArguments.self) { $args in ViewThatOpensInAWindow(args: args) } Is there any other way?
0
0
88
Apr ’25
How to import large data from Server and save it to Swift Data
Here’s the situation: • You’re downloading a huge list of data from iCloud. • You’re saving it one by one (sequentially) into SwiftData. • You don’t want the SwiftUI view to refresh until all the data is imported. • After all the import is finished, SwiftUI should show the new data. The Problem If you insert into the same ModelContext that SwiftUI’s @Environment(.modelContext) is watching, each insert may cause SwiftUI to start reloading immediately. That will make the UI feel slow, and glitchy, because SwiftUI will keep trying to re-render while you’re still importing. How to achieve this in Swift Data ?
2
0
147
Apr ’25
Is it possible to use an additional local ModelContainer in a document based SwiftData app?
I have a document based SwiftData app in which I would like to implement a persistent cache. For obvious reasons, I would not like to store the contents of the cache in the documents themselves, but in my app's data directory. Is a use case, in which a document based SwiftData app uses not only the ModelContainers from the currently open files, but also a ModelContainer writing a database file in the app's documents directory (for cache, settings, etc.) supported? If yes, how can you inject two different ModelContexts, one tied to the currently open file and one tied to the local database, into a SwiftUI view?
0
0
79
Apr ’25
Reply to 0xBAADCA11 Occurs when VoIP Call Incoming (APNs Push Notification)
If Wi-Fi is enabled when the sXGP-SIM is implemented, the crash that in step 8 of the [Operation] in the first explanation will occur 100%. Have you looked at exactly what happens when your app launches in that configuration? I don't see how this would change the systems routing for pushes, but I could see it distorting your apps own network logic. Also, how is the app being distributed to the device? I do not that there are extra verification steps for enterprise apps and, in theory, it's possible that issues with that verification process could delay the app launch long enough that callservicesd then terminates the app. my crash log was below. code:0xBAADCA11 explanation: Yes, that's the termination code. My question was what did the rest of the log show? Is there a way to send the logs other than uploading them directly here? You can either file a bug and post the number back here, or you can file a code level support request and send them through email. However, this is what I would generally prefer: If n
Topic: App & System Services SubTopic: General Tags:
Apr ’25
Reply to Need 3.1.3(f) Guidelines Clarification
Based on your quote and description, I would agree with your interpretation and confusion. But it is important to remember power discrepancies in any relationship. For all but a few developers, Apple holds all the power and can interpret e.g. to mean whatever it wants. I'm curious now. App Review says that they have resolved your issue. What was the resolution? What does e.g. mean in the context of the Apple App Review Guidelines? Does it mean for example or specifically?
Apr ’25
CloudKit is not synchronizing with coredata for relationships
In core-data I have a contact and location entity. I have one-to-many relationship from contact to locations and one-to-one from location to contact. I create contact in a seperate view and save it. Later I create a location, fetch the created contact, and save it while specifying the relationship between location and contact contact and test if it actually did it and it works. viewContext.perform { do { // Set relationship using the generated accessor method currentContact.addToLocations(location) try viewContext.save() print(Saved successfully. Locations count:, currentContact.locations?.count ?? 0) if let locs = currentContact.locations { print(📍 Contact has (locs.count) locations.) for loc in locs { print(➡️ Location: (String(describing: (loc as AnyObject).locationName ?? Unnamed))) } } } catch { print(Failed to save location: (error.localizedDescription)) } } In my NSManagedObject class properties I have this : for Contact: @NSManaged public var locations: NSSet? for Location:
0
0
128
Apr ’25
About the Relay payload
ios構成プロファイルの制限のallowCloudPrivateRelayのプライベートリレーの制御とRelayペイロードの機能は関係がありますか? それとも別々の機能でしょうか? ↓ s there a relationship between the private relay control in the iOS configuration profile restriction allowCloudPrivateRelay and the functionality of the Relay payload? Or are they separate features?
0
0
25
Apr ’25
SwiftData - disable Persistent History Tracking
Hello, I am building a pretty large database (~40MB) to be used in my SwiftData iOS app as read-only. While inserting and updating the data, I noticed a substantial increase in size (+ ~10MB). A little digging pointed to ACHANGE and ATRANSACTION tables that apparently are dealing with Persistent History Tracking. While I do appreciate the benefits of that, I prefer to save space. Could you please point me in the right direction?
0
0
112
Apr ’25
Reply to iOS 16.3 in Simulator
Definitely an issue in xCode 16.3 as it applies to inherited properties and the simulators. I can't diagnose why it's happening, but there are cases where the value shown in the debugger is not what it should be and that causes code to fail. What's crazy is that looking in the debugger at self.inheritedProperty and then expanding self and drilling down to inheritedProperty, the values do not match. The value on the self node is correct. The issue does not occur on a real device and Xcode 16.0 is still solid as it applies to simulators. Personally, I will be avoiding xCode 16.3 until Apple issues an update that addresses a fix for this.
Replies
Boosts
Views
Activity
Apr ’25
Stopping certain data models from syncing to cloudkit
Hi all, I am using SwiftData and cloudkit and I am having an extremely persistent bug. I am building an education section on a app that's populated with lessons via a local JSON file. I don't need this lesson data to sync to cloudkit as the lessons are static, just need them imported into swiftdata so I've tried to use the modelcontainer like this: static func createSharedModelContainer() -> ModelContainer { // --- Define Model Groups --- let localOnlyModels: [any PersistentModel.Type] = [ Lesson.self, MiniLesson.self, Quiz.self, Question.self ] let cloudKitSyncModels: [any PersistentModel.Type] = [ User.self, DailyTip.self, UserSubscription.self, UserEducationProgress.self // User progress syncs ] However, what happens is that I still get Lesson and MiniLesson record types on cloudkit and for some reason as well, whenever I update the data models or delete and reinstall the app on simulator, the lessons duplicate (what seems to happen is that a set of lessons comes from the JSON file as
Replies
0
Boosts
0
Views
113
Activity
Apr ’25
Reply to How to import large data from Server and save it to Swift Data
Do you know how much data is expected to be downloaded? If so, you could ensure the view doesn't update until the right amount of data is received and stored. If you don't know the quantity of data, you could add a Bool and toggle it when the data loading starts, then toggle it when the data has finished loading, so the View is only refreshed when the last of the data is stored. Another way would be to disable the UI so the user can't interact with it until the data has finished loading. The UI would update in the background, but the user wouldn't experience a slow UI as they can't interact with it anyway. You could put a partially-transparent View with a ProgressView in it at the top of a ZStack (which would be at the bottom of the ZStack in the code...) and hide it when you're done. I'll show you how I do it below. There's a few ways of doing it, but I don't think there's a built-in way to achieve this. But then, I'm not a genius on SwiftData, so... Using a blocking view: @State private var loading
Replies
Boosts
Views
Activity
Apr ’25
Open child windows for a document in a document based SwiftData app
In a document based SwiftData app for macOS, how do you go about opening a (modal) child window connected to the ModelContainer of the currently open document? Using .sheet() does not really result in a good UX, as the appearing view lacks the standard window toolbar. Using a separate WindowGroup with an argument would achieve the desired UX. However, as WindowGroup arguments need to be Hashable and Codable, there is no way to pass a ModelContainer or a ModelContext there: WindowGroup(id: myWindowGroup, for: MyWindowGroupArguments.self) { $args in ViewThatOpensInAWindow(args: args) } Is there any other way?
Replies
0
Boosts
0
Views
88
Activity
Apr ’25
How to import large data from Server and save it to Swift Data
Here’s the situation: • You’re downloading a huge list of data from iCloud. • You’re saving it one by one (sequentially) into SwiftData. • You don’t want the SwiftUI view to refresh until all the data is imported. • After all the import is finished, SwiftUI should show the new data. The Problem If you insert into the same ModelContext that SwiftUI’s @Environment(.modelContext) is watching, each insert may cause SwiftUI to start reloading immediately. That will make the UI feel slow, and glitchy, because SwiftUI will keep trying to re-render while you’re still importing. How to achieve this in Swift Data ?
Replies
2
Boosts
0
Views
147
Activity
Apr ’25
Is it possible to use an additional local ModelContainer in a document based SwiftData app?
I have a document based SwiftData app in which I would like to implement a persistent cache. For obvious reasons, I would not like to store the contents of the cache in the documents themselves, but in my app's data directory. Is a use case, in which a document based SwiftData app uses not only the ModelContainers from the currently open files, but also a ModelContainer writing a database file in the app's documents directory (for cache, settings, etc.) supported? If yes, how can you inject two different ModelContexts, one tied to the currently open file and one tied to the local database, into a SwiftUI view?
Replies
0
Boosts
0
Views
79
Activity
Apr ’25
Reply to SwiftData error: NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
I am receiving the same errors on Xcode 16.3 (16E140), using SwiftData but only simply types like String and Date with no transformations.
Replies
Boosts
Views
Activity
Apr ’25
Reply to 0xBAADCA11 Occurs when VoIP Call Incoming (APNs Push Notification)
If Wi-Fi is enabled when the sXGP-SIM is implemented, the crash that in step 8 of the [Operation] in the first explanation will occur 100%. Have you looked at exactly what happens when your app launches in that configuration? I don't see how this would change the systems routing for pushes, but I could see it distorting your apps own network logic. Also, how is the app being distributed to the device? I do not that there are extra verification steps for enterprise apps and, in theory, it's possible that issues with that verification process could delay the app launch long enough that callservicesd then terminates the app. my crash log was below. code:0xBAADCA11 explanation: Yes, that's the termination code. My question was what did the rest of the log show? Is there a way to send the logs other than uploading them directly here? You can either file a bug and post the number back here, or you can file a code level support request and send them through email. However, this is what I would generally prefer: If n
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Need 3.1.3(f) Guidelines Clarification
Based on your quote and description, I would agree with your interpretation and confusion. But it is important to remember power discrepancies in any relationship. For all but a few developers, Apple holds all the power and can interpret e.g. to mean whatever it wants. I'm curious now. App Review says that they have resolved your issue. What was the resolution? What does e.g. mean in the context of the Apple App Review Guidelines? Does it mean for example or specifically?
Replies
Boosts
Views
Activity
Apr ’25
Reply to SwiftData lazy loaded list
Any updates on this? I'm facing the same issue of @Query loading all the data at once. Is there a way to update the UI when a SwiftData model changes without using @Query?
Replies
Boosts
Views
Activity
Apr ’25
Reply to Crash in Widget extension
I'm using SwiftData in getTimeline() and I get the same crash
Replies
Boosts
Views
Activity
Apr ’25
CloudKit is not synchronizing with coredata for relationships
In core-data I have a contact and location entity. I have one-to-many relationship from contact to locations and one-to-one from location to contact. I create contact in a seperate view and save it. Later I create a location, fetch the created contact, and save it while specifying the relationship between location and contact contact and test if it actually did it and it works. viewContext.perform { do { // Set relationship using the generated accessor method currentContact.addToLocations(location) try viewContext.save() print(Saved successfully. Locations count:, currentContact.locations?.count ?? 0) if let locs = currentContact.locations { print(📍 Contact has (locs.count) locations.) for loc in locs { print(➡️ Location: (String(describing: (loc as AnyObject).locationName ?? Unnamed))) } } } catch { print(Failed to save location: (error.localizedDescription)) } } In my NSManagedObject class properties I have this : for Contact: @NSManaged public var locations: NSSet? for Location:
Replies
0
Boosts
0
Views
128
Activity
Apr ’25
About the Relay payload
ios構成プロファイルの制限のallowCloudPrivateRelayのプライベートリレーの制御とRelayペイロードの機能は関係がありますか? それとも別々の機能でしょうか? ↓ s there a relationship between the private relay control in the iOS configuration profile restriction allowCloudPrivateRelay and the functionality of the Relay payload? Or are they separate features?
Replies
0
Boosts
0
Views
25
Activity
Apr ’25
SwiftData - disable Persistent History Tracking
Hello, I am building a pretty large database (~40MB) to be used in my SwiftData iOS app as read-only. While inserting and updating the data, I noticed a substantial increase in size (+ ~10MB). A little digging pointed to ACHANGE and ATRANSACTION tables that apparently are dealing with Persistent History Tracking. While I do appreciate the benefits of that, I prefer to save space. Could you please point me in the right direction?
Replies
0
Boosts
0
Views
112
Activity
Apr ’25
Reply to Mac App Crashing with Illegal Instructions
Maybe the underscore in the property name is causing an issue, could you try with a different name? And shouldn't that property be private so you can only access the relationship in one way?
Replies
Boosts
Views
Activity
Apr ’25