Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Change to SwiftData ModelContainer causing crashes
I have some models in my app: [SDPlanBrief.self, SDAirport.self, SDChart.self, SDIndividualRunwayAirport.self, SDLocationBrief.self] SDLocationBrief has a @Relationship with SDChart When I went live with my app I didn't have a versioned schema, but quickly had to change that as I needed to add items to my SDPlanBrief Model. The first versioned schema I made included only the model that I had made a change to. static var models: [any PersistentModel.Type] { [SDPlanBrief.self] } I had made zero changes to my model container and the whole time, and it was working fine. The migration worked well and this is what I was using: .modelContainer(for: [SDAirport.self, SDIndividualRunwayAirport.self, SDLocationBrief.self, SDChart.self, SDPlanBrief.self]) I then saw that to do this all properly, I should actually include ALL of my @Models in the versioned schema: enum AllSwiftDataSchemaV3: VersionedSchema { static var models: [any PersistentModel.Type] { [SDPlanBrief.self, SDAirport.self, SDChart.self, SDIndivid
6
0
284
Jul ’25
Reply to Struggling With Guideline 4.3(b) Rejections – Would Love Dev Insight
Precedent & Fairness in Enforcement Rove is an intentional, safety-forward dating product. It is neither spammy, low-effort, nor duplicative — and yet we continue to face rejections under Guideline 4.3(b). This raises serious concerns about selective enforcement of App Store policy. In the past 60 days, Apple has approved a wide range of new dating apps, including: • Ready: Dating & Relationships – Launched June 3, 2025. Marketed as a native app for “intentional dating,” with a thematic approach directly comparable to Rove. • Meetline – Launched May 15, 2025. A transit-based connection app that limits conversations, just like Rove limits user visibility to avoid overload. • Yuzu – Asian Dating & Friends – A non-swipe app tailored to a specific community — proof that niche dating concepts are not inherently duplicative. • Metya / DateGuard – Two safety-first apps that use community filters and moderation-centric design. These are directionally aligned with Rove’s own innovation in safety a
Jul ’25
Reply to File/Folder access/scoping for background only apps
First off, ruling an issue out here: However, when our tool is installed from a Standard Account, the macOS messages asking for confirmation to access the Desktop or Documents or Downloads folder don’t appear and access to the file/folders is denied. Does your app include all of the relevant tcc strings (NSDesktopFolderUsageDescription, etc.)? Also, one thing to be careful of here is that there are a bunch of heuristics in this system that control how/when these are presented, which can make knowing why something is working a particular way difficult to determine. When you're looking closely at an issue like this, I'd always suggest working on a totally clean machine*, not your normal development machine. *VMs are handy for this, as you can get the system to a fully configured state, then duplicate the VM image so you can always start over from the same exact starting point. We install a Photoshop plug-in and it’s mainly a UI which then executes a background app containing the business logic to read/write fil
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’25
File/Folder access/scoping for background only apps
We create plug-ins for Adobe Creative Cloud and have run into an issue with respect to file/folder permissions. First, all of our libraries, code is code-signed and notarized as per Apple requirements but distribute outside of the Mac App store. We install a Photoshop plug-in and its mainly a UI which then executes a background app containing the business logic to read/write files. The background app runs as a separate process and is not in the Photoshop sandbox space so it doesn't inherit Photoshop permissions/scoping rules. Our plug-in communicates with the background process via ports etc. When a user chooses a file to process from lets say the Desktop, generally macOS first pops up a message that says ABCD background app is trying to access files from the Desktop do you grant it permission etc...This is also true for network mounted volumes or downloads folder. This message generally appears properly when everything is under an account with admin rights. However, when our tool is installed from a
8
0
210
Jul ’25
SwiftData and discarding unsaved changes idea???
Someone smarter than me please tell me if this will work... I want to have an edit screen for a SwiftData class. Auto Save is on, but I want to be able to revert changes. I have read all about sending a copy in, sending an ID and creating a new context without autosave, etc. What about simply creating a second set of ephemeral values in the actual original model. initialize them with the actual fields. Edit them and if you save changes, migrate that back to the permanent fields before returning. Don't have to manage a list of @State variables corresponding to every model field, and don't have to worry about a second model context. Anyone have any idea of the memory / performance implications of doing it this way, and if it is even possible? Does this just make a not quite simple situation even more complicated? Haven't tried yet, just got inspiration from reading some medium content on attributes on my lunch break, and wondering if I am just silly for considering it.
2
0
208
Jul ’25
Reply to Authorization Credentials Caching Implications
Thank you Quinn for the insights! It's quite a coincidence indeed, I hadn't seen that other thread yet! I think I found that ancient Q&A while searching the Documentation Archive for Authorization information (or maybe on a comment you left in an older thread). Before filing a bug report, I'd like to clarify whether this is actually a bug or simply a missing feature. What puzzles me specifically is the behavior of Activity Monitor.app: Even when I use rights that are explicitly configured as non-shared (like authenticate-admin-nonshared), Activity Monitor still appears to inherit the credentials. I also tried to configure com.apple.activitymonitor.kill with a timeout of 0, but that didn't help. The only way I've found to prevent this behavior is when the original application explicitly calls AuthorizationFree() with the .destroyRights flag. However, newer versions of System Settings don't have the lock icon you mentioned, so they appear to not be destroying these rights (even if I close the windo
Topic: Privacy & Security SubTopic: General Tags:
Jul ’25
Reply to SwiftData SortDescriptor Limitation...
I am not asking for help fixing a crash. I did that by commenting out one line of code where I was asking SwiftData to sort ModelA results on a title string from an associated ModelB object. ModeB has a one to many association to ModelA and must exist before any ModelA objects are created BUT CloudKit requires that you specify the relationships between these two models as Optional. Therefore when I tried to sort ModelA results by a Title in ModelB I needed to declare the property as a force unwrapped title of ModelB in the SortDescriptor. It would be ludicrous to try to show the actual code so that you can follow everything. Suffice it to say that this SortDescriptor was accepted by the compiler, and gave me exactly what I wanted when I ran the App either in a Simulator or on a device that downloaded the app from Xcode. BUT when the app was uploaded to the App Store and then downloaded from TestFlight the App would immediately crash with no useful error pointing to the problem. Bottom line i
Jul ’25
Reply to How can I get the system to use my FSModule for probing?
As a workaround, it does seem that if I log in to a GUI session as the root user (https://support.apple.com/en-us/102367) and enable my FSKit module as the root user in System Settings, then automount works (even from a regular user). Seems like some kind of “modules enabled as the logged in user” vs “modules enabled as the root user” discrepancy. Yeah, there are a bunch of places in the system where logging in as root will change the normal system behavior. There's a common Unix pattern macOS inherits, which is that the root is both a: Standard user account (which is why you can log in). The user ID the system uses as the owner ID for stuff it doesn't want some other specific user to own. Going back to here: enable my FSKit module as the root user in System Settings, then automount works (even from a regular user). What's going here is that there's a split between the system's extensions (which work) and the user's extensions (which should work, but don't). Strictly speaking, logging in as root shou
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’25
SwiftData SortDescriptor Limitation...
I built a SwiftData App that relies on CloudKit to synchronize data across devices. That means all model relationships must be expressed as Optional. That’s fine, but there is a limitation in using Optional’s in SwiftData SortDescriptors (Crashes App) That means I can’t apply a SortDescriptor to ModelA using some property value in ModelB (even if ModelB must exist) I tried using a computed property in ModelA that referred to the property in ModelB, BUT THIS DOESN”T WORK EITHER! Am I stuck storing redundant data In ModelA just to sort ModelA as I would like???
4
0
192
Jul ’25
SwiftData error: Attempting to retrieve an NSManagedObjectModel version checksum while the model is still editable
Hi, I'm getting a very odd error log in my SwiftData setup for an iOS app. It is implemented to support schema migration. When starting the app, it simply prints the following log twice (seems to be dependent on how many migration steps, I have two steps in my sample code): CoreData: error: Attempting to retrieve an NSManagedObjectModel version checksum while the model is still editable. This may result in an unstable verison checksum. Add model to NSPersistentStoreCoordinator and try again. (Yes there is a mistyped word verison, this is exactly the log) The code actually fully works. But I have neither CloudKit configured, nor is this app in Production yet. I'm still just developing. Here is the setup and code to reproduce the issue. Development mac version: macOS 15.5 XCode version: 16.4 iOS Simulator version: 18.5 Real iPhone version: 18.5 Project name: SwiftDataDebugApp SwiftDataDebugApp.swift: import SwiftUI import SwiftData @main struct SwiftDataDebugApp: App { var sharedModelContainer
2
0
157
Jul ’25
How can I find the user's "Favorite Songs" playlist?
It sounds simple but searching for the name Favorite Songs is a non-starter because it's called different names in different countries, even if I specify &l=en_us on the query. So is there another property, relationship or combination thereof which I can use to tell me when I've found the right playlist? Properties I've looked at so far: canEdit: will always be false so narrows things down a little inFavorites: not helpful as it depends on whether the user has favourite the favourites playlist, so not relevant hasCatalog: seems always true so again may narrow things down a bit isPublic: doesn't help Adding the catalog relationship doesn't seem to show anything immediately useful either. Can anyone help? Ideally I'd like to see this as a kind or type as it has different properties to other playlists, but frankly I'll take anything at this point.
0
0
298
Jul ’25
Reply to Detecting When App Token Is Removed Due to Category Selection in FamilyActivityPicker
[quote='791334021, Nasheet, /thread/791334, /profile/Nasheet'] does the system not give access to the relationship between apps and their categories [/quote] This is not possible unfortunately. I desperately need the same functionality for my app as well. A while ago I sent a feedback request / radar to Apple but haven’t heard anything back: FB16121372 I would urge you to file a feedback request as well: Demonstrate your use-case. Showcase how this would not affect user-privacy (you still don‘t know which app and category are represented by each token, you just know that they’re related). Post your feedback number here as well 🙌 Let’s work on this together and shape the future of the Screen Time API – such an important topic nowadays that deserves more attention by Apple!
Topic: App & System Services SubTopic: General Tags:
Jul ’25
Extending @Model with custom macros
I am trying to extend my PersistedModels like so: @Versioned(3) @Model class MyType { var name: String init() { name = hello } } but it seems that SwiftData's@Model macro is unable to read the properties added by my @Versioned macro. I have tried changing the order and it ignores them regardless. version is not added to schemaMetadata and version needs to be persisted. I was planning on using this approach to add multiple capabilities to my model types. Is this possible to do with macros? VersionedMacro /// A macro that automatically implements VersionedModel protocol public struct VersionedMacro: MemberMacro, ExtensionMacro { // Member macro to add the stored property directly to the type public static func expansion( of node: AttributeSyntax, providingMembersOf declaration: some DeclGroupSyntax, in context: some MacroExpansionContext ) throws -> [DeclSyntax] { guard let argumentList = node.arguments?.as(LabeledExprListSyntax.self), let firstArgument = argumentList.first?.expression else { throw
1
0
421
Jul ’25
Change to SwiftData ModelContainer causing crashes
I have some models in my app: [SDPlanBrief.self, SDAirport.self, SDChart.self, SDIndividualRunwayAirport.self, SDLocationBrief.self] SDLocationBrief has a @Relationship with SDChart When I went live with my app I didn't have a versioned schema, but quickly had to change that as I needed to add items to my SDPlanBrief Model. The first versioned schema I made included only the model that I had made a change to. static var models: [any PersistentModel.Type] { [SDPlanBrief.self] } I had made zero changes to my model container and the whole time, and it was working fine. The migration worked well and this is what I was using: .modelContainer(for: [SDAirport.self, SDIndividualRunwayAirport.self, SDLocationBrief.self, SDChart.self, SDPlanBrief.self]) I then saw that to do this all properly, I should actually include ALL of my @Models in the versioned schema: enum AllSwiftDataSchemaV3: VersionedSchema { static var models: [any PersistentModel.Type] { [SDPlanBrief.self, SDAirport.self, SDChart.self, SDIndivid
Replies
6
Boosts
0
Views
284
Activity
Jul ’25
Reply to Struggling With Guideline 4.3(b) Rejections – Would Love Dev Insight
Precedent & Fairness in Enforcement Rove is an intentional, safety-forward dating product. It is neither spammy, low-effort, nor duplicative — and yet we continue to face rejections under Guideline 4.3(b). This raises serious concerns about selective enforcement of App Store policy. In the past 60 days, Apple has approved a wide range of new dating apps, including: • Ready: Dating & Relationships – Launched June 3, 2025. Marketed as a native app for “intentional dating,” with a thematic approach directly comparable to Rove. • Meetline – Launched May 15, 2025. A transit-based connection app that limits conversations, just like Rove limits user visibility to avoid overload. • Yuzu – Asian Dating & Friends – A non-swipe app tailored to a specific community — proof that niche dating concepts are not inherently duplicative. • Metya / DateGuard – Two safety-first apps that use community filters and moderation-centric design. These are directionally aligned with Rove’s own innovation in safety a
Replies
Boosts
Views
Activity
Jul ’25
Reply to File/Folder access/scoping for background only apps
First off, ruling an issue out here: However, when our tool is installed from a Standard Account, the macOS messages asking for confirmation to access the Desktop or Documents or Downloads folder don’t appear and access to the file/folders is denied. Does your app include all of the relevant tcc strings (NSDesktopFolderUsageDescription, etc.)? Also, one thing to be careful of here is that there are a bunch of heuristics in this system that control how/when these are presented, which can make knowing why something is working a particular way difficult to determine. When you're looking closely at an issue like this, I'd always suggest working on a totally clean machine*, not your normal development machine. *VMs are handy for this, as you can get the system to a fully configured state, then duplicate the VM image so you can always start over from the same exact starting point. We install a Photoshop plug-in and it’s mainly a UI which then executes a background app containing the business logic to read/write fil
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’25
File/Folder access/scoping for background only apps
We create plug-ins for Adobe Creative Cloud and have run into an issue with respect to file/folder permissions. First, all of our libraries, code is code-signed and notarized as per Apple requirements but distribute outside of the Mac App store. We install a Photoshop plug-in and its mainly a UI which then executes a background app containing the business logic to read/write files. The background app runs as a separate process and is not in the Photoshop sandbox space so it doesn't inherit Photoshop permissions/scoping rules. Our plug-in communicates with the background process via ports etc. When a user chooses a file to process from lets say the Desktop, generally macOS first pops up a message that says ABCD background app is trying to access files from the Desktop do you grant it permission etc...This is also true for network mounted volumes or downloads folder. This message generally appears properly when everything is under an account with admin rights. However, when our tool is installed from a
Replies
8
Boosts
0
Views
210
Activity
Jul ’25
SwiftData and discarding unsaved changes idea???
Someone smarter than me please tell me if this will work... I want to have an edit screen for a SwiftData class. Auto Save is on, but I want to be able to revert changes. I have read all about sending a copy in, sending an ID and creating a new context without autosave, etc. What about simply creating a second set of ephemeral values in the actual original model. initialize them with the actual fields. Edit them and if you save changes, migrate that back to the permanent fields before returning. Don't have to manage a list of @State variables corresponding to every model field, and don't have to worry about a second model context. Anyone have any idea of the memory / performance implications of doing it this way, and if it is even possible? Does this just make a not quite simple situation even more complicated? Haven't tried yet, just got inspiration from reading some medium content on attributes on my lunch break, and wondering if I am just silly for considering it.
Replies
2
Boosts
0
Views
208
Activity
Jul ’25
Reply to Authorization Credentials Caching Implications
Thank you Quinn for the insights! It's quite a coincidence indeed, I hadn't seen that other thread yet! I think I found that ancient Q&A while searching the Documentation Archive for Authorization information (or maybe on a comment you left in an older thread). Before filing a bug report, I'd like to clarify whether this is actually a bug or simply a missing feature. What puzzles me specifically is the behavior of Activity Monitor.app: Even when I use rights that are explicitly configured as non-shared (like authenticate-admin-nonshared), Activity Monitor still appears to inherit the credentials. I also tried to configure com.apple.activitymonitor.kill with a timeout of 0, but that didn't help. The only way I've found to prevent this behavior is when the original application explicitly calls AuthorizationFree() with the .destroyRights flag. However, newer versions of System Settings don't have the lock icon you mentioned, so they appear to not be destroying these rights (even if I close the windo
Topic: Privacy & Security SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’25
Reply to SwiftData SortDescriptor Limitation...
I am not asking for help fixing a crash. I did that by commenting out one line of code where I was asking SwiftData to sort ModelA results on a title string from an associated ModelB object. ModeB has a one to many association to ModelA and must exist before any ModelA objects are created BUT CloudKit requires that you specify the relationships between these two models as Optional. Therefore when I tried to sort ModelA results by a Title in ModelB I needed to declare the property as a force unwrapped title of ModelB in the SortDescriptor. It would be ludicrous to try to show the actual code so that you can follow everything. Suffice it to say that this SortDescriptor was accepted by the compiler, and gave me exactly what I wanted when I ran the App either in a Simulator or on a device that downloaded the app from Xcode. BUT when the app was uploaded to the App Store and then downloaded from TestFlight the App would immediately crash with no useful error pointing to the problem. Bottom line i
Replies
Boosts
Views
Activity
Jul ’25
Reply to How can I get the system to use my FSModule for probing?
As a workaround, it does seem that if I log in to a GUI session as the root user (https://support.apple.com/en-us/102367) and enable my FSKit module as the root user in System Settings, then automount works (even from a regular user). Seems like some kind of “modules enabled as the logged in user” vs “modules enabled as the root user” discrepancy. Yeah, there are a bunch of places in the system where logging in as root will change the normal system behavior. There's a common Unix pattern macOS inherits, which is that the root is both a: Standard user account (which is why you can log in). The user ID the system uses as the owner ID for stuff it doesn't want some other specific user to own. Going back to here: enable my FSKit module as the root user in System Settings, then automount works (even from a regular user). What's going here is that there's a split between the system's extensions (which work) and the user's extensions (which should work, but don't). Strictly speaking, logging in as root shou
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’25
SwiftData SortDescriptor Limitation...
I built a SwiftData App that relies on CloudKit to synchronize data across devices. That means all model relationships must be expressed as Optional. That’s fine, but there is a limitation in using Optional’s in SwiftData SortDescriptors (Crashes App) That means I can’t apply a SortDescriptor to ModelA using some property value in ModelB (even if ModelB must exist) I tried using a computed property in ModelA that referred to the property in ModelB, BUT THIS DOESN”T WORK EITHER! Am I stuck storing redundant data In ModelA just to sort ModelA as I would like???
Replies
4
Boosts
0
Views
192
Activity
Jul ’25
SwiftData error: Attempting to retrieve an NSManagedObjectModel version checksum while the model is still editable
Hi, I'm getting a very odd error log in my SwiftData setup for an iOS app. It is implemented to support schema migration. When starting the app, it simply prints the following log twice (seems to be dependent on how many migration steps, I have two steps in my sample code): CoreData: error: Attempting to retrieve an NSManagedObjectModel version checksum while the model is still editable. This may result in an unstable verison checksum. Add model to NSPersistentStoreCoordinator and try again. (Yes there is a mistyped word verison, this is exactly the log) The code actually fully works. But I have neither CloudKit configured, nor is this app in Production yet. I'm still just developing. Here is the setup and code to reproduce the issue. Development mac version: macOS 15.5 XCode version: 16.4 iOS Simulator version: 18.5 Real iPhone version: 18.5 Project name: SwiftDataDebugApp SwiftDataDebugApp.swift: import SwiftUI import SwiftData @main struct SwiftDataDebugApp: App { var sharedModelContainer
Replies
2
Boosts
0
Views
157
Activity
Jul ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
The only way around it I've found is to create an intermediate 1:1 model that contains the 1:N relationship since SwiftData won't query 1:1 relationships by default.
Replies
Boosts
Views
Activity
Jul ’25
How can I find the user's "Favorite Songs" playlist?
It sounds simple but searching for the name Favorite Songs is a non-starter because it's called different names in different countries, even if I specify &l=en_us on the query. So is there another property, relationship or combination thereof which I can use to tell me when I've found the right playlist? Properties I've looked at so far: canEdit: will always be false so narrows things down a little inFavorites: not helpful as it depends on whether the user has favourite the favourites playlist, so not relevant hasCatalog: seems always true so again may narrow things down a bit isPublic: doesn't help Adding the catalog relationship doesn't seem to show anything immediately useful either. Can anyone help? Ideally I'd like to see this as a kind or type as it has different properties to other playlists, but frankly I'll take anything at this point.
Replies
0
Boosts
0
Views
298
Activity
Jul ’25
Reply to Detecting When App Token Is Removed Due to Category Selection in FamilyActivityPicker
[quote='791334021, Nasheet, /thread/791334, /profile/Nasheet'] does the system not give access to the relationship between apps and their categories [/quote] This is not possible unfortunately. I desperately need the same functionality for my app as well. A while ago I sent a feedback request / radar to Apple but haven’t heard anything back: FB16121372 I would urge you to file a feedback request as well: Demonstrate your use-case. Showcase how this would not affect user-privacy (you still don‘t know which app and category are represented by each token, you just know that they’re related). Post your feedback number here as well 🙌 Let’s work on this together and shape the future of the Screen Time API – such an important topic nowadays that deserves more attention by Apple!
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
@DTS Engineer This is still an issue. For now we stopped using relationships. Instead we store IDs and load entities lazy when accessed.
Replies
Boosts
Views
Activity
Jul ’25
Extending @Model with custom macros
I am trying to extend my PersistedModels like so: @Versioned(3) @Model class MyType { var name: String init() { name = hello } } but it seems that SwiftData's@Model macro is unable to read the properties added by my @Versioned macro. I have tried changing the order and it ignores them regardless. version is not added to schemaMetadata and version needs to be persisted. I was planning on using this approach to add multiple capabilities to my model types. Is this possible to do with macros? VersionedMacro /// A macro that automatically implements VersionedModel protocol public struct VersionedMacro: MemberMacro, ExtensionMacro { // Member macro to add the stored property directly to the type public static func expansion( of node: AttributeSyntax, providingMembersOf declaration: some DeclGroupSyntax, in context: some MacroExpansionContext ) throws -> [DeclSyntax] { guard let argumentList = node.arguments?.as(LabeledExprListSyntax.self), let firstArgument = argumentList.first?.expression else { throw
Replies
1
Boosts
0
Views
421
Activity
Jul ’25