Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to Does Core Spotlight work with document-based apps?
The issue is that Spotlight APIs appear to be App based & not Document based. Sort of. I think the better way to understand this is that the API was intentionally broadened to cover non-document data, but that shift also makes the API appear more app based. I can't find a way to separate Spotlight data by document. Note the contentURL property of CSSearchableItemAttributeSet, which is how you'd note the document location. So you'll end up creating multiple CSSearchableItems for every document, all of which (for a given document) will have the same content URL. I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations. My guess here is that this is fairly slow, because you're basically searching everything and then discarding results down
Topic: App & System Services SubTopic: General Tags:
Jun ’25
Reply to NSTableView is unresponsive when inside a modal window shown in DispatchQueue.main.async
Thanks for the explanation. So is using perform(_:with:afterDelay:) or Timer.scheduledTimer(withTimeInterval:repeats:block:) the correct way in this case? I thought using DispatchQueue.main.async was the most elegant way, as it's succinct and allows me to call a native Swift method with a native Swift argument, but because of the modal table view unresponsiveness it's out of the question. Timer.scheduledTimer(withTimeInterval:repeats:block:) is less intuitive and a little longer, but works in this case, so it's my best option for now. perform(_:with:afterDelay:) requires the first argument to be a @objc method, which in turn requires its own argument to be representable in Objective C (which I did by inheriting from NSObject, quite an overhead).
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’25
Migrating Sign in with Apple users for an app transfer
Question detail Dear Apple Developer Technical Support, We are currently following the official Apple documentation “TN3159: Migrating Sign in with Apple users for an app transfer” to carry out a Sign in with Apple user migration after successfully transferring several apps to a new developer account. Here is a summary of our situation: Under the original Apple developer account, we had five apps using Sign in with Apple, grouped under a shared primary app using App Grouping. Recently, we transferred three of these apps to our new Apple developer account via App Store Connect. After the transfer, these three apps are no longer associated with the original primary App ID. We reconfigured individual Services IDs for each app in the new account and enabled Sign in with Apple for each. More than 24 hours have passed since the app transfer was completed. Now we are attempting to follow the migration process to restore user access via the user.migration flow. Specifically, we are using the following script to reque
2
0
572
Jun ’25
Can a ReferenceFileDocument be @Observable?
Although I can't see anything in Apple's documentation to this effect, I'm coming to believe that ReferenceFileDocument is incompatible with @Observable. But hopefully I've just missed something! I have an app in which the data model is @Observable, and views see it through @Environment(dataModel.self) private var dataModel Since there are a large number of views, only some of which may need to be redrawn at a given time, Apple's documentation leads me to believe that @Observable may be smarter about only redrawing views that actually need redrawing than @Published and @ObservedObject. I originally wrote the app without document persistence, and injected the data model into the environment like this: @main struct MyApp: App { @State private var dataModel = DataModel() var body: some Scene { WindowGroup { myDocumentView() .environment(dataModel) } } } I’ve been trying to make the app document based. Although I started using SwiftData, it has trouble with Codable (you need to explicitly code each eleme
3
0
192
Jun ’25
Reply to Autogenerated UI Test Runner Blocked By Local Network Permission Prompt
I ended up trying the last two approaches that I mentioned: Running the CI/CD connector directly from Terminal.app Running the CI/CD connector directly from a local ssh session I figured these last two were the most direct in trying to exercise the listed carve outs in TN3179: Understanding local network privacy | Apple Developer Documentation which states: Command-line tools run from Terminal or over SSH, including any child processes they spawn Between each of these tests I restarted the machine since it seems that that's the only reliable way to reset the state for this mechanism on macOS 15.5. Running directly from Terminal.app Here is an annotated screenshot from running directly from Terminal.app Here is a description of each numbered point of interest in this screenshot: You can see that i'm simply directly executing the script from https://github.com/actions/runner/blob/main/src/Misc/layoutroot/run.sh to run the CI/CD connector. I'm ssh'd into the CI machine from a different machine to show the proces
Jun ’25
SwiftData .deny deleteRule not working
I tried to use the .deny deleteRule but it seems to have no effect. The toolbar button adds an item with a relationship to a category to the context. Swiping on the category deletes the category even though an item is referencing the category. There is also no error thrown when saving the context. It is as if the deleteRule was not there. For other deleteRules like .cascade, the provided sample code works as expected. import SwiftUI import SwiftData @Model class Category { var name: String @Relationship(deleteRule: .deny) var items: [Item] = [] init(name: String) { self.name = name } } @Model class Item { var name: String var category: Category? init(name: String, category: Category) { self.name = name self.category = category } } struct DenyDeleteRule: View { @Environment(.modelContext) private var modelContext @Query private var categories: [Category] @Query private var items: [Item] var body: some View { List { Section(Items) { ForEach(items) { item in Text(item.name) } } Section
1
0
107
Jun ’25
Migrating Sign in with Apple users for an app transfer
Dear Apple Developer Technical Support, We are currently following the official Apple documentation “TN3159: Migrating Sign in with Apple users for an app transfer” to carry out a Sign in with Apple user migration after successfully transferring several apps to a new developer account. Here is a summary of our situation: Under the original Apple developer account, we had five apps using Sign in with Apple, grouped under a shared primary app using App Grouping. Recently, we transferred three of these apps to our new Apple developer account via App Store Connect. After the transfer, these three apps are no longer associated with the original primary App ID. We reconfigured individual Services IDs for each app in the new account and enabled Sign in with Apple for each. More than 24 hours have passed since the app transfer was completed. Now we are attempting to follow the migration process to restore user access via the user.migration flow. Specifically, we are using the following script to request an Apple acce
3
0
414
Jun ’25
Does Core Spotlight work with document-based apps?
I have a SwiftUI document-based app that for the sake of this discussion stores accounting information: chart of accounts, transactions, etc. Each document is backed by a SwiftData DB. I'd like to incorporate search into the app so that users can find transactions matching certain criteria, so I went to Core Spotlight. Indexing & search within the app seem to work well. The issue is that Spotlight APIs appear to be App based & not Document based. I can't find a way to separate Spotlight data by document. I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations. Index updates via CSSearchableIndexDelegate.reindex* methods seem to be App-centric. A user may have file #1 open, but the delegate is being asked to update CSSearcha
7
0
255
Jun ’25
Module not found when using inheritance
PLATFORM AND VERSION Development environment: Xcode 16.4 (16F6), macOS 15.5 (24F74) Run-time configuration: iOS 18.3.1 DESCRIPTION OF PROBLEM I cannot build my app due to a module not found error when I'm importing Sample-Swift.h header to an ObjectiveC file. I need to use Swift code to ObjectiveC file with Swift code using an external XCFramework. It seems to be related to a mix with ObjectiveC and Swift code when Swift code uses class inheritance from FZWorkoutKit class. With a full Swift project, no issue. STEPS TO REPRODUCE Project https://fizzup.s3.amazonaws.com/files/public/Sample-WK.zip Open the provided project and try to build it. The issue occurs. In MyObject.m file, if you comment the first import (Sample-Swift.h), no issue occurs but I cannot use my Swift code (MyFile class). Uncomment the line commented in step 1. Go to MyFile.swift and change class inheritance from GoModeController (from FZWorkoutKit framework) to UIView (from UIKit). No issue occurs.
0
0
121
Jun ’25
Error querying optional Codable with SwiftData
I'm building a SwiftUI app using SwiftData. In my app I have a Customer model with an optional codable structure Contact. Below is a simplified version of my model: @Model class Customer { var name: String = var contact: Contact? init(name: String, contact: Contact? = nil) { self.name = name self.contact = contact } struct Contact: Codable, Equatable { var phone: String var email: String var allowSMS: Bool } } I'm trying to query all the Customers that have a contact with @Query. For example: @Query(filter: #Predicate { customer in customer.contact != nil }) var customers: [Customer] However no matter how I set the predicate I always get an error: BugDemo crashed due to an uncaught exception NSInvalidArgumentException. Reason: keypath contact not found in entity Customer. How can I fix this so that I'm able to filter by contact not nil in my Model?
2
0
273
Jun ’25
Reply to Autogenerated UI Test Runner Blocked By Local Network Permission Prompt
We only support macOS virtualisation on Mac hardware. Are you planning to run your own hardware? Or are you planning to build your CI system on top of a virtualisation service from another company? And if you plan to run your own hardware, roughly how many hosts are we talking about? We run 80+ physical Mac Mini's for our CI/CD needs. We're attempting to build virtualization on top of these machines to make it easier to restore the CI environment to a known, good state after runs. Today we register each machine in the developer portal and integrate it into our provisioning profiles. However, with VM through the Virtaulization.framework in order to reset to a clean state we have to boot a new VM, which gives us a new UDID. Registering each one of these would easily blow past the registered device limits stipulated in https://developer.apple.com/help/account/devices/devices-overview. I’d like to clarify my understanding of this setup. Specifically, is the ↳ symbol meant to represent a dependency? Or a flow of c
Jun ’25
Reply to Does Core Spotlight work with document-based apps?
The issue is that Spotlight APIs appear to be App based & not Document based. Sort of. I think the better way to understand this is that the API was intentionally broadened to cover non-document data, but that shift also makes the API appear more app based. I can't find a way to separate Spotlight data by document. Note the contentURL property of CSSearchableItemAttributeSet, which is how you'd note the document location. So you'll end up creating multiple CSSearchableItems for every document, all of which (for a given document) will have the same content URL. I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations. My guess here is that this is fairly slow, because you're basically searching everything and then discarding results down
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to NSTableView is unresponsive when inside a modal window shown in DispatchQueue.main.async
Thanks for the explanation. So is using perform(_:with:afterDelay:) or Timer.scheduledTimer(withTimeInterval:repeats:block:) the correct way in this case? I thought using DispatchQueue.main.async was the most elegant way, as it's succinct and allows me to call a native Swift method with a native Swift argument, but because of the modal table view unresponsiveness it's out of the question. Timer.scheduledTimer(withTimeInterval:repeats:block:) is less intuitive and a little longer, but works in this case, so it's my best option for now. perform(_:with:afterDelay:) requires the first argument to be a @objc method, which in turn requires its own argument to be representable in Objective C (which I did by inheriting from NSObject, quite an overhead).
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to SectionedFetchRequest in SwiftData
I’ve submitted a feedback request to Apple: FB18281742, requesting native sectioned grouping support in SwiftData similar to Core Data’s @SectionedFetchRequest.
Replies
Boosts
Views
Activity
Jun ’25
Migrating Sign in with Apple users for an app transfer
Question detail Dear Apple Developer Technical Support, We are currently following the official Apple documentation “TN3159: Migrating Sign in with Apple users for an app transfer” to carry out a Sign in with Apple user migration after successfully transferring several apps to a new developer account. Here is a summary of our situation: Under the original Apple developer account, we had five apps using Sign in with Apple, grouped under a shared primary app using App Grouping. Recently, we transferred three of these apps to our new Apple developer account via App Store Connect. After the transfer, these three apps are no longer associated with the original primary App ID. We reconfigured individual Services IDs for each app in the new account and enabled Sign in with Apple for each. More than 24 hours have passed since the app transfer was completed. Now we are attempting to follow the migration process to restore user access via the user.migration flow. Specifically, we are using the following script to reque
Replies
2
Boosts
0
Views
572
Activity
Jun ’25
Reply to Data Race in Widgets?
If it’s UI facing or some SwiftData related, you need to use with @MainActor. but ideally provide more information.
Replies
Boosts
Views
Activity
Jun ’25
Reply to Error querying optional Codable with SwiftData
Use a separate @Model class Contact instead, works well for me. Even though Contact is Codable in your code, SwiftData does not store it like a model class.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’25
Can a ReferenceFileDocument be @Observable?
Although I can't see anything in Apple's documentation to this effect, I'm coming to believe that ReferenceFileDocument is incompatible with @Observable. But hopefully I've just missed something! I have an app in which the data model is @Observable, and views see it through @Environment(dataModel.self) private var dataModel Since there are a large number of views, only some of which may need to be redrawn at a given time, Apple's documentation leads me to believe that @Observable may be smarter about only redrawing views that actually need redrawing than @Published and @ObservedObject. I originally wrote the app without document persistence, and injected the data model into the environment like this: @main struct MyApp: App { @State private var dataModel = DataModel() var body: some Scene { WindowGroup { myDocumentView() .environment(dataModel) } } } I’ve been trying to make the app document based. Although I started using SwiftData, it has trouble with Codable (you need to explicitly code each eleme
Replies
3
Boosts
0
Views
192
Activity
Jun ’25
Reply to Autogenerated UI Test Runner Blocked By Local Network Permission Prompt
I ended up trying the last two approaches that I mentioned: Running the CI/CD connector directly from Terminal.app Running the CI/CD connector directly from a local ssh session I figured these last two were the most direct in trying to exercise the listed carve outs in TN3179: Understanding local network privacy | Apple Developer Documentation which states: Command-line tools run from Terminal or over SSH, including any child processes they spawn Between each of these tests I restarted the machine since it seems that that's the only reliable way to reset the state for this mechanism on macOS 15.5. Running directly from Terminal.app Here is an annotated screenshot from running directly from Terminal.app Here is a description of each numbered point of interest in this screenshot: You can see that i'm simply directly executing the script from https://github.com/actions/runner/blob/main/src/Misc/layoutroot/run.sh to run the CI/CD connector. I'm ssh'd into the CI machine from a different machine to show the proces
Replies
Boosts
Views
Activity
Jun ’25
SwiftData .deny deleteRule not working
I tried to use the .deny deleteRule but it seems to have no effect. The toolbar button adds an item with a relationship to a category to the context. Swiping on the category deletes the category even though an item is referencing the category. There is also no error thrown when saving the context. It is as if the deleteRule was not there. For other deleteRules like .cascade, the provided sample code works as expected. import SwiftUI import SwiftData @Model class Category { var name: String @Relationship(deleteRule: .deny) var items: [Item] = [] init(name: String) { self.name = name } } @Model class Item { var name: String var category: Category? init(name: String, category: Category) { self.name = name self.category = category } } struct DenyDeleteRule: View { @Environment(.modelContext) private var modelContext @Query private var categories: [Category] @Query private var items: [Item] var body: some View { List { Section(Items) { ForEach(items) { item in Text(item.name) } } Section
Replies
1
Boosts
0
Views
107
Activity
Jun ’25
Migrating Sign in with Apple users for an app transfer
Dear Apple Developer Technical Support, We are currently following the official Apple documentation “TN3159: Migrating Sign in with Apple users for an app transfer” to carry out a Sign in with Apple user migration after successfully transferring several apps to a new developer account. Here is a summary of our situation: Under the original Apple developer account, we had five apps using Sign in with Apple, grouped under a shared primary app using App Grouping. Recently, we transferred three of these apps to our new Apple developer account via App Store Connect. After the transfer, these three apps are no longer associated with the original primary App ID. We reconfigured individual Services IDs for each app in the new account and enabled Sign in with Apple for each. More than 24 hours have passed since the app transfer was completed. Now we are attempting to follow the migration process to restore user access via the user.migration flow. Specifically, we are using the following script to request an Apple acce
Replies
3
Boosts
0
Views
414
Activity
Jun ’25
Reply to defaultIsolation option and Core Data
I think what you did - adding nonisolated - is correct. Also needed for SwiftData and at-ModelActor.
Replies
Boosts
Views
Activity
Jun ’25
Does Core Spotlight work with document-based apps?
I have a SwiftUI document-based app that for the sake of this discussion stores accounting information: chart of accounts, transactions, etc. Each document is backed by a SwiftData DB. I'd like to incorporate search into the app so that users can find transactions matching certain criteria, so I went to Core Spotlight. Indexing & search within the app seem to work well. The issue is that Spotlight APIs appear to be App based & not Document based. I can't find a way to separate Spotlight data by document. I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations. Index updates via CSSearchableIndexDelegate.reindex* methods seem to be App-centric. A user may have file #1 open, but the delegate is being asked to update CSSearcha
Replies
7
Boosts
0
Views
255
Activity
Jun ’25
Module not found when using inheritance
PLATFORM AND VERSION Development environment: Xcode 16.4 (16F6), macOS 15.5 (24F74) Run-time configuration: iOS 18.3.1 DESCRIPTION OF PROBLEM I cannot build my app due to a module not found error when I'm importing Sample-Swift.h header to an ObjectiveC file. I need to use Swift code to ObjectiveC file with Swift code using an external XCFramework. It seems to be related to a mix with ObjectiveC and Swift code when Swift code uses class inheritance from FZWorkoutKit class. With a full Swift project, no issue. STEPS TO REPRODUCE Project https://fizzup.s3.amazonaws.com/files/public/Sample-WK.zip Open the provided project and try to build it. The issue occurs. In MyObject.m file, if you comment the first import (Sample-Swift.h), no issue occurs but I cannot use my Swift code (MyFile class). Uncomment the line commented in step 1. Go to MyFile.swift and change class inheritance from GoModeController (from FZWorkoutKit framework) to UIView (from UIKit). No issue occurs.
Replies
0
Boosts
0
Views
121
Activity
Jun ’25
Error querying optional Codable with SwiftData
I'm building a SwiftUI app using SwiftData. In my app I have a Customer model with an optional codable structure Contact. Below is a simplified version of my model: @Model class Customer { var name: String = var contact: Contact? init(name: String, contact: Contact? = nil) { self.name = name self.contact = contact } struct Contact: Codable, Equatable { var phone: String var email: String var allowSMS: Bool } } I'm trying to query all the Customers that have a contact with @Query. For example: @Query(filter: #Predicate { customer in customer.contact != nil }) var customers: [Customer] However no matter how I set the predicate I always get an error: BugDemo crashed due to an uncaught exception NSInvalidArgumentException. Reason: keypath contact not found in entity Customer. How can I fix this so that I'm able to filter by contact not nil in my Model?
Replies
2
Boosts
0
Views
273
Activity
Jun ’25
Reply to Autogenerated UI Test Runner Blocked By Local Network Permission Prompt
We only support macOS virtualisation on Mac hardware. Are you planning to run your own hardware? Or are you planning to build your CI system on top of a virtualisation service from another company? And if you plan to run your own hardware, roughly how many hosts are we talking about? We run 80+ physical Mac Mini's for our CI/CD needs. We're attempting to build virtualization on top of these machines to make it easier to restore the CI environment to a known, good state after runs. Today we register each machine in the developer portal and integrate it into our provisioning profiles. However, with VM through the Virtaulization.framework in order to reset to a clean state we have to boot a new VM, which gives us a new UDID. Registering each one of these would easily blow past the registered device limits stipulated in https://developer.apple.com/help/account/devices/devices-overview. I’d like to clarify my understanding of this setup. Specifically, is the ↳ symbol meant to represent a dependency? Or a flow of c
Replies
Boosts
Views
Activity
Jun ’25