Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

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
Aug ’25
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
Reply to [TextKit2] - Wrong document height sometimes ?
Are you using the system-provided NSTextView, or are you writing your own custom text view using TextKit2? I've tested both during my investigation: Custom text view - inherits NSView & using TextKit2: I'm able to reproduce the issue mentioned above (Xcode 16.4 - macOS 15.6) Custom text view - inherits NSTextView & using TextKit2: I'm able to reproduce the issue mentioned above (Xcode 16.4 - macOS 15.6) System-provided NSTextView: OK (Xcode 16.4 - macOS 15.6) It really seems to be because of what value is returned by : enumerateTextLayoutFragments(from: documentRange.endLocation, options: [.reverse, .ensuresLayout]) { layoutFragment in ... layoutFragment.layoutFragmentFrame.maxY ... } For your own custom text view, you should be able to fix the issue by adjusting the viewport. This post provides a code snippet for that purpose. Please see if that helps. Yes indeed, I read this post and I can make a workaround with (OR without adjusting the viewport by ensuring a layout at appropriate
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’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
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Just noticed that I hadn't responded this post. Sorry for that ... I tried the sample project (thanks to @dasdasda) and reproduced the issue on iOS 26 (Beta 4) – fetching Item indeed fetches its itemLinks relationship, even though the relationship is not accessed. Do you have a feedback report yet? If not, I’d suggest that you file one and share your report ID here. (I can file a report as well, but you represent the developer community. As an originator, you can get notified of the status change and follow up with it if that matters to you.) Best, —— Ziqiao Chen  Worldwide Developer Relations.
Aug ’25
Reply to es_mute_path() vs. deprecated es_mute_path_literal() - incompatibility and wrong documentation
That should be it. Thank you. But I urge you to re-read the canonical documentation in the headers. The difference you point out here (between PATH_TYPE_TARGET_LITERAL and PATH_TYPE_LITERAL) is not written there. The very simple distinction between the path of the executable creating the event and the path of the file which is the target of the event -- is simply not there. Yes, it could definitely be clearer on that point. It was fairly clear in the original API (when all you could block was by process), but when TARGET was added, it was documented in great detail, but we didn't go back and include a clear definition of the original constant. I just filed a bug asking for us to clarify the two roles in the enum definition comments. Having said that, this flowchart at line ~500 of ESClient.h does do a good job of describing what's going on, though it does not directly reference the specific constants involved: * The relationship between all three types of muting (proc,path,target-path) and how each c
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’25
Using relationships in SortDescriptor crashing on release
If use a SortDescriptor for a model and sort by some attribute from a relationship, in DEBUG mode it all works fine and sorts. However, in release mode, it is an instant crash. SortDescriptor(.name, order: .reverse) ---- works SortDescriptor(.assignedUser?.name, order: .reverse) ---- works in debug but crash in release. What is the issue here, is it that SwiftData just incompetent to do this?
2
0
125
Aug ’25
Reply to SwiftData crash when using a @Query sort descriptor with a relationship
@DTS Engineer this is still an issue in iOS 26 when sorting on a property of an optional relationship. @Query(sort: Item.info?.endDate, order: .reverse) private var items: [Item] @Model final class Item { var info: ItemInfo? init(info: ItemInfo) { self.info = info } } @Model final class ItemInfo { var endDate: Date init(endDate: Date) { self.endDate = endDate } } SwiftData/DataUtilities.swift:85: Fatal error: Couldn't find Item.)>?.? on Item with fields [SwiftData.Schema.PropertyMetadata(name: info, keypath: Item.)>, defaultValue: nil, metadata: nil)] iOS Simulator 26.0 beta 4 (23A5297i) Xcode Version 26.0 beta 4 (17A5285i) I made a minimal fork of the project @Atletismo343 provided: https://github.com/coughski/swiftdata-crash
Aug ’25
UITabBar hitTest method is not triggered when click button that is a subview of UITabBar and the subview frame is beyond UITabBar when using Xcode26 build app on OS 26
In our project, we defined a CustomTabBar that inherits UITabBar, and we add some subviews and these subviews' frame is beyond UITabBar, see below picture(a beyond area button, this button is a subview of UITabBar, but frame is out of UITabBar's area): and in order to let this button response to click action, we override the UITabBar's hitTest method, this works well below OS 26 with Xcode version below 26: override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let pointInCollectionView = self.beyondAreaButton.convert(point, from: self) if self.beyondAreaButton.bounds.contains(pointInCollectionView) { return self.beyondAreaButton.hitTest(pointInCollectionView, with: event) } return super.hitTest(point, with: event) } but when using Xcode26 build app on OS 26, I noticed the UITabBar is wrapped by a UIKit._UITabBarContainerView and UIKit._UITabBarContainerWrapperView, and it can not trigger the hitTest method. since the hitTest is not triggered, so the button action is no
1
0
228
Jul ’25
Reply to Upgrading an SMAppService daemon and changing the plist
[quote='851343022, nkirby, /thread/795022?answerId=851343022#851343022, /profile/nkirby'] We split the application from a monolithic binary into separate GUI and daemon executables. [/quote] Oh, yeah, that makes sense now that I look back at the property lists in your first post. [quote='851343022, nkirby, /thread/795022?answerId=851343022#851343022, /profile/nkirby'] Is there a way to tell launchd about the change? [/quote] Not that I’m aware of. Just as an experiment, if you override the code signing identifier of the daemon to match that of the main app, does that fix this problem? If you’er using code, change the code signing identifier by setting the Other Code Signing Flags build setting to [ $(inherited), --identifier, org.mozilla.macos.FirefoxVPN]. IMPORTANT I see a lot of folks put a lot of weird stuff in the Other Code Signing Flags build setting. I recommend against that in general, but it is a reasonable way to override the code signing identifier in a program that has no bundle ID. Share
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’25
Could not build Module 'UIKit'
Im currentrly having this issue when compiling iOS for my react native app. The error is Could not build Module 'UIKit' which brings more subsequent errors down the line like Could not build module 'DarwinFoundation' and Could not build module 'Foundation'. Might it be an error of dependencies or something like that. Im currently on MacOS sequoia, running XCode 16 and trying to build on iOS 18 with react native 0.75.3. For context, i inherited the project with React native 0.69.7 and had to upgrade. Please help, i've been stuck for days and i do not know what to do. Everything in the internet talks about XCode 16 beta but not the actual public release.
2
0
2.5k
Sep ’24
How to get full raw data of barcode using AVFoundation framework
I am creating a barcode reader using the AVfoundation framework for iOS and IPadOS. The read result goes into payloadstringvalue, but I want to check the control characters contained in the symbol, so I am using the raw data of the description, which is a property of NSObjectProtocol inherited by VNBarcodeObservation. However, I noticed that if the length set in the raw data exceeds 26, some of the raw data in the description is omitted. So my question is, is it possible to set it so that all the raw data in the description is written out without omitting any raw data? If so, could you please tell me how to set this up? Also, if you know of any other way to extract the raw barcode data, I would appreciate it if you could let me know. Thank you.
1
0
671
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
Aug ’25
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
Reply to [TextKit2] - Wrong document height sometimes ?
Are you using the system-provided NSTextView, or are you writing your own custom text view using TextKit2? I've tested both during my investigation: Custom text view - inherits NSView & using TextKit2: I'm able to reproduce the issue mentioned above (Xcode 16.4 - macOS 15.6) Custom text view - inherits NSTextView & using TextKit2: I'm able to reproduce the issue mentioned above (Xcode 16.4 - macOS 15.6) System-provided NSTextView: OK (Xcode 16.4 - macOS 15.6) It really seems to be because of what value is returned by : enumerateTextLayoutFragments(from: documentRange.endLocation, options: [.reverse, .ensuresLayout]) { layoutFragment in ... layoutFragment.layoutFragmentFrame.maxY ... } For your own custom text view, you should be able to fix the issue by adjusting the viewport. This post provides a code snippet for that purpose. Please see if that helps. Yes indeed, I read this post and I can make a workaround with (OR without adjusting the viewport by ensuring a layout at appropriate
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Aug ’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
Aug ’25
Reply to Fetching data with relationships directly faults the relationships even when not accessed
Just noticed that I hadn't responded this post. Sorry for that ... I tried the sample project (thanks to @dasdasda) and reproduced the issue on iOS 26 (Beta 4) – fetching Item indeed fetches its itemLinks relationship, even though the relationship is not accessed. Do you have a feedback report yet? If not, I’d suggest that you file one and share your report ID here. (I can file a report as well, but you represent the developer community. As an originator, you can get notified of the status change and follow up with it if that matters to you.) Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Aug ’25
Reply to SwiftData crash when using a @Query sort descriptor with a relationship
Indeed... The original issue, which was fixed in iOS 18.4, doesn't sort with an optional relationship. I see this crash a different issue. Do you have a feedback report yet? If not, would you mind to file one for us and share your report ID here? Thanks! Best, —— Ziqiao Chen  Worldwide Developer Relations.
Replies
Boosts
Views
Activity
Aug ’25
Reply to es_mute_path() vs. deprecated es_mute_path_literal() - incompatibility and wrong documentation
That should be it. Thank you. But I urge you to re-read the canonical documentation in the headers. The difference you point out here (between PATH_TYPE_TARGET_LITERAL and PATH_TYPE_LITERAL) is not written there. The very simple distinction between the path of the executable creating the event and the path of the file which is the target of the event -- is simply not there. Yes, it could definitely be clearer on that point. It was fairly clear in the original API (when all you could block was by process), but when TARGET was added, it was documented in great detail, but we didn't go back and include a clear definition of the original constant. I just filed a bug asking for us to clarify the two roles in the enum definition comments. Having said that, this flowchart at line ~500 of ESClient.h does do a good job of describing what's going on, though it does not directly reference the specific constants involved: * The relationship between all three types of muting (proc,path,target-path) and how each c
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Using relationships in SortDescriptor crashing on release
@DTS Engineer the issue @Ches Beiner brought up is still an issue, as detailed in my post on the thread you linked to: SwiftData crash when using a @Query sort descriptor with a relationship
Replies
Boosts
Views
Activity
Aug ’25
Using relationships in SortDescriptor crashing on release
If use a SortDescriptor for a model and sort by some attribute from a relationship, in DEBUG mode it all works fine and sorts. However, in release mode, it is an instant crash. SortDescriptor(.name, order: .reverse) ---- works SortDescriptor(.assignedUser?.name, order: .reverse) ---- works in debug but crash in release. What is the issue here, is it that SwiftData just incompetent to do this?
Replies
2
Boosts
0
Views
125
Activity
Aug ’25
Reply to SwiftData crash when using a @Query sort descriptor with a relationship
@DTS Engineer this is still an issue in iOS 26 when sorting on a property of an optional relationship. @Query(sort: Item.info?.endDate, order: .reverse) private var items: [Item] @Model final class Item { var info: ItemInfo? init(info: ItemInfo) { self.info = info } } @Model final class ItemInfo { var endDate: Date init(endDate: Date) { self.endDate = endDate } } SwiftData/DataUtilities.swift:85: Fatal error: Couldn't find Item.)>?.? on Item with fields [SwiftData.Schema.PropertyMetadata(name: info, keypath: Item.)>, defaultValue: nil, metadata: nil)] iOS Simulator 26.0 beta 4 (23A5297i) Xcode Version 26.0 beta 4 (17A5285i) I made a minimal fork of the project @Atletismo343 provided: https://github.com/coughski/swiftdata-crash
Replies
Boosts
Views
Activity
Aug ’25
UITabBar hitTest method is not triggered when click button that is a subview of UITabBar and the subview frame is beyond UITabBar when using Xcode26 build app on OS 26
In our project, we defined a CustomTabBar that inherits UITabBar, and we add some subviews and these subviews' frame is beyond UITabBar, see below picture(a beyond area button, this button is a subview of UITabBar, but frame is out of UITabBar's area): and in order to let this button response to click action, we override the UITabBar's hitTest method, this works well below OS 26 with Xcode version below 26: override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let pointInCollectionView = self.beyondAreaButton.convert(point, from: self) if self.beyondAreaButton.bounds.contains(pointInCollectionView) { return self.beyondAreaButton.hitTest(pointInCollectionView, with: event) } return super.hitTest(point, with: event) } but when using Xcode26 build app on OS 26, I noticed the UITabBar is wrapped by a UIKit._UITabBarContainerView and UIKit._UITabBarContainerWrapperView, and it can not trigger the hitTest method. since the hitTest is not triggered, so the button action is no
Replies
1
Boosts
0
Views
228
Activity
Jul ’25
Reply to Upgrading an SMAppService daemon and changing the plist
[quote='851343022, nkirby, /thread/795022?answerId=851343022#851343022, /profile/nkirby'] We split the application from a monolithic binary into separate GUI and daemon executables. [/quote] Oh, yeah, that makes sense now that I look back at the property lists in your first post. [quote='851343022, nkirby, /thread/795022?answerId=851343022#851343022, /profile/nkirby'] Is there a way to tell launchd about the change? [/quote] Not that I’m aware of. Just as an experiment, if you override the code signing identifier of the daemon to match that of the main app, does that fix this problem? If you’er using code, change the code signing identifier by setting the Other Code Signing Flags build setting to [ $(inherited), --identifier, org.mozilla.macos.FirefoxVPN]. IMPORTANT I see a lot of folks put a lot of weird stuff in the Other Code Signing Flags build setting. I recommend against that in general, but it is a reasonable way to override the code signing identifier in a program that has no bundle ID. Share
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’25
Could not build Module 'UIKit'
Im currentrly having this issue when compiling iOS for my react native app. The error is Could not build Module 'UIKit' which brings more subsequent errors down the line like Could not build module 'DarwinFoundation' and Could not build module 'Foundation'. Might it be an error of dependencies or something like that. Im currently on MacOS sequoia, running XCode 16 and trying to build on iOS 18 with react native 0.75.3. For context, i inherited the project with React native 0.69.7 and had to upgrade. Please help, i've been stuck for days and i do not know what to do. Everything in the internet talks about XCode 16 beta but not the actual public release.
Replies
2
Boosts
0
Views
2.5k
Activity
Sep ’24
How to get full raw data of barcode using AVFoundation framework
I am creating a barcode reader using the AVfoundation framework for iOS and IPadOS. The read result goes into payloadstringvalue, but I want to check the control characters contained in the symbol, so I am using the raw data of the description, which is a property of NSObjectProtocol inherited by VNBarcodeObservation. However, I noticed that if the length set in the raw data exceeds 26, some of the raw data in the description is omitted. So my question is, is it possible to set it so that all the raw data in the description is written out without omitting any raw data? If so, could you please tell me how to set this up? Also, if you know of any other way to extract the raw barcode data, I would appreciate it if you could let me know. Thank you.
Replies
1
Boosts
0
Views
671
Activity
Jul ’25
Reply to SwiftData migration error: NSCloudKitMirroringDelegate are not reusable
Did anyone have an update? I'm still facing the same issue. Not being able to do even trivial custom migrations seems like it makes SwiftData a complete non-starter.
Replies
Boosts
Views
Activity
Jul ’25