Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to How to listen for QUIC connections using the new NetworkListener in iOS 26?
@DTS Engineer I was hoping the evolution of the relationship of QUIC and the new API you mentioned would happen during the 26 beta period. But at this point it seems that it will be impossible to receive QUIC connections using the new APIs in iOS/iPadOS 26 and I'll likely have to wait another year or hope for changes in a dot release? As far as I can tell there have been no changes to the API in this respect as of beta 6, correct?
Aug ’25
Can SMAppService Daemon replace SMJobBless for exclusive HID capture from keyboards?
To gain exclusive access to keyboard HID devices like Amazon Fire Bluetooth remote controls, my app has been installing a privileged helper tool with SMJobBless in the past. The app - which also has Accessibility permissions - then invoked and communicated with that helper tool through XPC. Now I'm looking into replacing that with a daemon installed through the newer SMAppService APIs, but running into a permission problem: If I try to exclusively open a keyboard HID device from the SMAppService-registered XPC service/daemon (which runs as root as seen in Activity Monitor), IOHIDDeviceOpen returns kIOReturnNotPermitted. I've spent many hours now trying to get it to work, but so far didn't find a solution. Could it be that XPC services registered as a daemon through SMAppService do not inherit the TCC permissions from the invoking process (here: Accessibility permissions) - and the exclusive IOHIDDeviceOpen therefore fails?
7
0
320
Aug ’25
Reply to Compile Failure on NSXPCInterface Initializer
@DTS Engineer, I'm still getting the issue even with the Foundation module qualifier in the front of NSXPCInterface. The strangest thing is that I have others on my team that can build successfully with the same commit on the same version of XCode. I suspect something more environmental to my machine. I noticed that when I Jump to Definition on NSXPCInterface, XCode sometimes points me to the Swift definition of the interface, like below: @available(macOS 10.8, *) open class NSXPCInterface : NSObject { public /*not inherited*/ init(with protocol: Protocol) unowned(unsafe) open var `protocol`: Protocol //... } and other times it will point me to NSXPCConnection.h, like below: API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0)) @interface NSXPCInterface : NSObject // Factory method to get an NSXPCInterface instance for a given protocol. Most interfaces do not need any further configuration. Interfaces with collection classes or additional proxy objects should be configured using the methods b
Aug ’25
Safari App Extension fails to connect to CloudKit daemon (cloudd) with XPC communication errors -- CKErrorDomain Code=6 / NSCocoaErrorDomain Code=4099 – Unable to connect to CloudKit daemon
I'm working on a macOS app with a Safari web extension. I'm trying to share a SwiftData model between devices using CloudKit synchronization. I am able to get synchronization in the main app on the same device, CloudKit sync works correctly — changes appear in the CloudKit Dashboard under com.apple.coredata.cloudkit.zone. However, in the Safari App Extension, data is saved locally and persists across launches, but never syncs to CloudKit. I have followed the recommended practices for configuring the App Group and entitlements, but the issue persists. Questions: Is there an official limitation preventing Safari App Extensions from connecting to the CloudKit daemon (cloudd)? If not, what entitlements or configuration changes are required for a Safari App Extension to successfully sync with CloudKit? Is the xpc_error=159 from bootstrap_look_up() a known sandbox restriction for this extension type? Any guidance from Apple engineers or others who have successfully used CloudKit from a Safari App Extension
2
0
146
Aug ’25
Reply to Safari App Extension fails to connect to CloudKit daemon (cloudd) with XPC communication errors -- CKErrorDomain Code=6 / NSCocoaErrorDomain Code=4099 – Unable to connect to CloudKit daemon
This topic is discussed in the following technote section: Avoid synchronizing a store with multiple persistent containers. The technote is about NSPersistentCloudKitContainer. As of today, SwiftData (DefaultStore) + CloudKit uses NSPersistentCloudKitContainer under the hood, and so the content applies. Basically, the use case of sharing a CloudKit-back store between a main app and its extension and synchronizing with NSPersistentCloudKitContainer isn't quite supported, and so you might consider avoiding do that. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Aug ’25
Using Dynamic Member Lookup in a Superclass
As a fun project, I'm wanting to model an electronic circuit. Components inherit from a superclass (ElectronicComponent). Each subclass (e.g. Resistor) has certain methods to return properties (e.g. resistance), but may vary by the number of outlets (leads) they have, and what they are named. Each outlet connects to a Junction. In my code to assemble a circuit, while I'm able to manually hook up the outlets to the junctions, I'd like to be able to use code similar to the following… class Lead: Hashable // implementation omitted { let id = UUID() unowned let component: ElectronicComponent weak var connection: Junction? init(component: ElectronicComponent, to connection: Junction? = nil) { self.component = component self.connection = connection } } @dynamicMemberLookup class ElectronicComponent { let id = UUID() var connections: Set = [] let label: String? init(label: String) { self.label = label } subscript(dynamicMember keyPath: KeyPath) -> T { self[keyPath: keyPath] } func connect(lead: KeyPath,
6
0
479
Aug ’25
Reply to Using Dynamic Member Lookup in a Superclass
Thanks for the suggestion. 1 cent is not valueless when someone has nothing! This is my first venture into implementing dynamic member lookup. I'm at the stage where I believe I understand it – until I have to explain it, at which point I realise I really have no idea. Your suggestion gave me a momentary epiphany about a possible solution, so tried to understand the code better. At this stage, I'm thinking it still won't achieve my goal – having the compiler behave as though the method had been inherited by the subclasses, including auto-complete. FYI Following @DTS Engineer Quinn's suggestion, I've reposted the question at swift.org, but essentially given up on the approach I was hoping for. Having said that, your comment still feels worth exploring to see how far I can get.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to visionOS: Unable to programmatically close child WindowGroup when parent window closes
Hello @Jir_253, Thanks for your questions. I’d recommend that you start by watching Set the scene with SwiftUI in visionOS from this year’s WWDC. Your “CWindow” sounds similar to the Tools window covered in this talk: WindowGroup(Tools, id: tools) { ToolsView() } .restorationBehavior(.disabled) .defaultLaunchBehavior(.suppressed) Similar to iOS where you cannot quit the application yourself, you cannot dismiss the last window of your application. When a user goes to close the main window when the secondary window is open, you cannot close this secondary window if it’s the only window group that is open in your application. Consider adding an affordance to the secondary window to reopen the main window in this case. There's no supported way for you to create parent/child window relationships with the APIs currently available. If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number
Topic: Spatial Computing SubTopic: General Tags:
Aug ’25
visionOS: Unable to programmatically close child WindowGroup when parent window closes
Hi , I'm struggling with visionOS window management and need help with closing child windows programmatically. App Structure My app has a Main-Sub window hierarchy: AWindow (Home/Main) BWindow (Main feature window) CWindow (Tool window - child of BWindow) Navigation flow: AWindow → BWindow (switch, 1 window on screen) BWindow → CWindow (opens child, 2 windows on screen) I want BWindow and CWindow to be separate movable windows (not sheet/popover) so users can position them independently in space. The Problem CWindow doesn't close when BWindow closes by tapping the X button below the app (next to the window bar) User clicks X on BWindow → BWindow closes but CWindow remains CWindow becomes orphaned on screen Can close CWindow programmatically when switching BWindow back to AWindow App launch issue After closing both windows, CWindow is remembered as last window Reopening app shows only CWindow instead of BWindow User gets stuck in CWindow with no way back to BWindow I've Tried Environment dismissWindow in clean
2
0
367
Aug ’25
Fetching data with relationships directly faults the relationships even when not accessed
I am using SwiftData to model my data. For that i created a model called OrganizationData that contains various relationships to other entities. My data set is quite large and i am having a big performance issue when fetching all OrganizationData entities. I started debugging and looking at the sql debug log i noticed that when fetching my entities i run into faults for all relationships even when not accessing them. Fetching my entities: let fetchDescriptor = FetchDescriptor() let context = MapperContext(dataManager: self) let organizations = (try modelContainer.mainContext.fetch(fetchDescriptor)) Doing this fetch, also fetches all relationships. Each in a single query, for every OrganizationData entity. CoreData: annotation: to-many relationship fault relationship1 for objectID 0x8aa5249772916e00 fulfilled from database. Got 9 rows CoreData: annotation: to-many relationship fault relationship2 for objectID 0x8aa5249772916e00 fulfilled from database. Go
14
0
454
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Indeed. I looked more closely into the SQLite debug log: CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZID, t0.ZSOMEPROPERTY, t0.ZSOMEPROPERTY2 FROM ZITEM t0 CoreData: annotation: sql connection fetch time: 0.0001s CoreData: annotation: total fetch execution time: 0.0002s for 4 rows. CoreData: sql: SELECT 0, t0.Z_PK FROM ZITEM1TO2LINK t0 WHERE t0.ZITEM = ? CoreData: annotation: sql connection fetch time: 0.0001s CoreData: annotation: total fetch execution time: 0.0001s for 4 rows. CoreData: annotation: to-many relationship fault itemLinks for objectID 0x904a44aa77e3d40d fulfilled from database. Got 4 rows ... The SQL to fetch the itemLinks relationship (SELECT 0, t0.Z_PK FROM ZITEM1TO2LINK t0 WHERE t0.ZITEM = ? ) is basically only for the primary key, and so I won't expect that has a significant performance impact. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Thanks for the replay. I did not create a feedback report yet but will create one. For now we moved away from relationships as this was having a big performance impact with our quite large data set. Instead our entities only store IDs of related entities. This prevents any loading of all the related entities, but adds a bit of manual work to handle the lazy loading.
Aug ’25
Reply to Am I allowed to use FFMPEG and FFPROBE binaries in Mac App Store?
There are two parts to questions like this: What’s technically feasible? What’s required by App Review? I don’t work for App Review, so I can’t offer definitive advice on their policies. I recommend that you review their published guidelines. I’m happy to wade into technical questions. And on that front, you wrote: [quote='795751021, maarten1987, /thread/795751, /profile/maarten1987'] I can not run this in sandbox mode. [/quote] Why not? In general, sandboxed apps are allowed to: Play and record audio Have embedded helper executables Spawn child processes Given that, I can’t see any fundamental reason why this won’t work. So I recommend that you dig further into the failure, because that’s likely to be a lot more fun than the alternatives. Note It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits. [quote='852254022, Tomato, /thread/795751?answerId=852254022#852254022, /profile/Tomato'] you can have your users download the command-line tool
Aug ’25
Reply to How to listen for QUIC connections using the new NetworkListener in iOS 26?
@DTS Engineer I was hoping the evolution of the relationship of QUIC and the new API you mentioned would happen during the 26 beta period. But at this point it seems that it will be impossible to receive QUIC connections using the new APIs in iOS/iPadOS 26 and I'll likely have to wait another year or hope for changes in a dot release? As far as I can tell there have been no changes to the API in this respect as of beta 6, correct?
Replies
Boosts
Views
Activity
Aug ’25
Can SMAppService Daemon replace SMJobBless for exclusive HID capture from keyboards?
To gain exclusive access to keyboard HID devices like Amazon Fire Bluetooth remote controls, my app has been installing a privileged helper tool with SMJobBless in the past. The app - which also has Accessibility permissions - then invoked and communicated with that helper tool through XPC. Now I'm looking into replacing that with a daemon installed through the newer SMAppService APIs, but running into a permission problem: If I try to exclusively open a keyboard HID device from the SMAppService-registered XPC service/daemon (which runs as root as seen in Activity Monitor), IOHIDDeviceOpen returns kIOReturnNotPermitted. I've spent many hours now trying to get it to work, but so far didn't find a solution. Could it be that XPC services registered as a daemon through SMAppService do not inherit the TCC permissions from the invoking process (here: Accessibility permissions) - and the exclusive IOHIDDeviceOpen therefore fails?
Replies
7
Boosts
0
Views
320
Activity
Aug ’25
Reply to Compile Failure on NSXPCInterface Initializer
@DTS Engineer, I'm still getting the issue even with the Foundation module qualifier in the front of NSXPCInterface. The strangest thing is that I have others on my team that can build successfully with the same commit on the same version of XCode. I suspect something more environmental to my machine. I noticed that when I Jump to Definition on NSXPCInterface, XCode sometimes points me to the Swift definition of the interface, like below: @available(macOS 10.8, *) open class NSXPCInterface : NSObject { public /*not inherited*/ init(with protocol: Protocol) unowned(unsafe) open var `protocol`: Protocol //... } and other times it will point me to NSXPCConnection.h, like below: API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0)) @interface NSXPCInterface : NSObject // Factory method to get an NSXPCInterface instance for a given protocol. Most interfaces do not need any further configuration. Interfaces with collection classes or additional proxy objects should be configured using the methods b
Replies
Boosts
Views
Activity
Aug ’25
Safari App Extension fails to connect to CloudKit daemon (cloudd) with XPC communication errors -- CKErrorDomain Code=6 / NSCocoaErrorDomain Code=4099 – Unable to connect to CloudKit daemon
I'm working on a macOS app with a Safari web extension. I'm trying to share a SwiftData model between devices using CloudKit synchronization. I am able to get synchronization in the main app on the same device, CloudKit sync works correctly — changes appear in the CloudKit Dashboard under com.apple.coredata.cloudkit.zone. However, in the Safari App Extension, data is saved locally and persists across launches, but never syncs to CloudKit. I have followed the recommended practices for configuring the App Group and entitlements, but the issue persists. Questions: Is there an official limitation preventing Safari App Extensions from connecting to the CloudKit daemon (cloudd)? If not, what entitlements or configuration changes are required for a Safari App Extension to successfully sync with CloudKit? Is the xpc_error=159 from bootstrap_look_up() a known sandbox restriction for this extension type? Any guidance from Apple engineers or others who have successfully used CloudKit from a Safari App Extension
Replies
2
Boosts
0
Views
146
Activity
Aug ’25
Reply to Safari App Extension fails to connect to CloudKit daemon (cloudd) with XPC communication errors -- CKErrorDomain Code=6 / NSCocoaErrorDomain Code=4099 – Unable to connect to CloudKit daemon
This topic is discussed in the following technote section: Avoid synchronizing a store with multiple persistent containers. The technote is about NSPersistentCloudKitContainer. As of today, SwiftData (DefaultStore) + CloudKit uses NSPersistentCloudKitContainer under the hood, and so the content applies. Basically, the use case of sharing a CloudKit-back store between a main app and its extension and synchronizing with NSPersistentCloudKitContainer isn't quite supported, and so you might consider avoiding do that. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Aug ’25
Using Dynamic Member Lookup in a Superclass
As a fun project, I'm wanting to model an electronic circuit. Components inherit from a superclass (ElectronicComponent). Each subclass (e.g. Resistor) has certain methods to return properties (e.g. resistance), but may vary by the number of outlets (leads) they have, and what they are named. Each outlet connects to a Junction. In my code to assemble a circuit, while I'm able to manually hook up the outlets to the junctions, I'd like to be able to use code similar to the following… class Lead: Hashable // implementation omitted { let id = UUID() unowned let component: ElectronicComponent weak var connection: Junction? init(component: ElectronicComponent, to connection: Junction? = nil) { self.component = component self.connection = connection } } @dynamicMemberLookup class ElectronicComponent { let id = UUID() var connections: Set = [] let label: String? init(label: String) { self.label = label } subscript(dynamicMember keyPath: KeyPath) -> T { self[keyPath: keyPath] } func connect(lead: KeyPath,
Replies
6
Boosts
0
Views
479
Activity
Aug ’25
Reply to Using Dynamic Member Lookup in a Superclass
Thanks for the suggestion. 1 cent is not valueless when someone has nothing! This is my first venture into implementing dynamic member lookup. I'm at the stage where I believe I understand it – until I have to explain it, at which point I realise I really have no idea. Your suggestion gave me a momentary epiphany about a possible solution, so tried to understand the code better. At this stage, I'm thinking it still won't achieve my goal – having the compiler behave as though the method had been inherited by the subclasses, including auto-complete. FYI Following @DTS Engineer Quinn's suggestion, I've reposted the question at swift.org, but essentially given up on the approach I was hoping for. Having said that, your comment still feels worth exploring to see how far I can get.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to visionOS: Unable to programmatically close child WindowGroup when parent window closes
Hello @Jir_253, Thanks for your questions. I’d recommend that you start by watching Set the scene with SwiftUI in visionOS from this year’s WWDC. Your “CWindow” sounds similar to the Tools window covered in this talk: WindowGroup(Tools, id: tools) { ToolsView() } .restorationBehavior(.disabled) .defaultLaunchBehavior(.suppressed) Similar to iOS where you cannot quit the application yourself, you cannot dismiss the last window of your application. When a user goes to close the main window when the secondary window is open, you cannot close this secondary window if it’s the only window group that is open in your application. Consider adding an affordance to the secondary window to reopen the main window in this case. There's no supported way for you to create parent/child window relationships with the APIs currently available. If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number
Topic: Spatial Computing SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’25
visionOS: Unable to programmatically close child WindowGroup when parent window closes
Hi , I'm struggling with visionOS window management and need help with closing child windows programmatically. App Structure My app has a Main-Sub window hierarchy: AWindow (Home/Main) BWindow (Main feature window) CWindow (Tool window - child of BWindow) Navigation flow: AWindow → BWindow (switch, 1 window on screen) BWindow → CWindow (opens child, 2 windows on screen) I want BWindow and CWindow to be separate movable windows (not sheet/popover) so users can position them independently in space. The Problem CWindow doesn't close when BWindow closes by tapping the X button below the app (next to the window bar) User clicks X on BWindow → BWindow closes but CWindow remains CWindow becomes orphaned on screen Can close CWindow programmatically when switching BWindow back to AWindow App launch issue After closing both windows, CWindow is remembered as last window Reopening app shows only CWindow instead of BWindow User gets stuck in CWindow with no way back to BWindow I've Tried Environment dismissWindow in clean
Replies
2
Boosts
0
Views
367
Activity
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Interesting thanks for that. If that is the case the log is indeed misleading and their might be something else that caused the performance issues we had with relationships. As we currently see a significant improvement compared to our initial implementation.
Replies
Boosts
Views
Activity
Aug ’25
Fetching data with relationships directly faults the relationships even when not accessed
I am using SwiftData to model my data. For that i created a model called OrganizationData that contains various relationships to other entities. My data set is quite large and i am having a big performance issue when fetching all OrganizationData entities. I started debugging and looking at the sql debug log i noticed that when fetching my entities i run into faults for all relationships even when not accessing them. Fetching my entities: let fetchDescriptor = FetchDescriptor() let context = MapperContext(dataManager: self) let organizations = (try modelContainer.mainContext.fetch(fetchDescriptor)) Doing this fetch, also fetches all relationships. Each in a single query, for every OrganizationData entity. CoreData: annotation: to-many relationship fault relationship1 for objectID 0x8aa5249772916e00 fulfilled from database. Got 9 rows CoreData: annotation: to-many relationship fault relationship2 for objectID 0x8aa5249772916e00 fulfilled from database. Go
Replies
14
Boosts
0
Views
454
Activity
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Indeed. I looked more closely into the SQLite debug log: CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZID, t0.ZSOMEPROPERTY, t0.ZSOMEPROPERTY2 FROM ZITEM t0 CoreData: annotation: sql connection fetch time: 0.0001s CoreData: annotation: total fetch execution time: 0.0002s for 4 rows. CoreData: sql: SELECT 0, t0.Z_PK FROM ZITEM1TO2LINK t0 WHERE t0.ZITEM = ? CoreData: annotation: sql connection fetch time: 0.0001s CoreData: annotation: total fetch execution time: 0.0001s for 4 rows. CoreData: annotation: to-many relationship fault itemLinks for objectID 0x904a44aa77e3d40d fulfilled from database. Got 4 rows ... The SQL to fetch the itemLinks relationship (SELECT 0, t0.Z_PK FROM ZITEM1TO2LINK t0 WHERE t0.ZITEM = ? ) is basically only for the primary key, and so I won't expect that has a significant performance impact. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
The log lines are actually misleading, it is NOT faulting in the related Models but gathering the related PersistentIdentifiers to use when the relationship is traversed.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Thanks for the replay. I did not create a feedback report yet but will create one. For now we moved away from relationships as this was having a big performance impact with our quite large data set. Instead our entities only store IDs of related entities. This prevents any loading of all the related entities, but adds a bit of manual work to handle the lazy loading.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Am I allowed to use FFMPEG and FFPROBE binaries in Mac App Store?
There are two parts to questions like this: What’s technically feasible? What’s required by App Review? I don’t work for App Review, so I can’t offer definitive advice on their policies. I recommend that you review their published guidelines. I’m happy to wade into technical questions. And on that front, you wrote: [quote='795751021, maarten1987, /thread/795751, /profile/maarten1987'] I can not run this in sandbox mode. [/quote] Why not? In general, sandboxed apps are allowed to: Play and record audio Have embedded helper executables Spawn child processes Given that, I can’t see any fundamental reason why this won’t work. So I recommend that you dig further into the failure, because that’s likely to be a lot more fun than the alternatives. Note It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits. [quote='852254022, Tomato, /thread/795751?answerId=852254022#852254022, /profile/Tomato'] you can have your users download the command-line tool
Replies
Boosts
Views
Activity
Aug ’25