Post

Replies

Boosts

Views

Activity

Reply to SwiftData - Context missing for optional
I also tried changing the method of deletion to the following. This tries to delete entity Object that has a to-many relationship children: [Child]. guard let id = object.id else { return } do { try container.mainContext.delete(model: Object.self, where: #Predicate { object in object.id == id }) } catch { print(error) } This does not crash the app, but fails to delete the entity with the following console output: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={Reason=Entity named:Object not found for relationship named:children, MissingEntity=Object. (<NSEntityDescription: 0x6000035100b0>) ... I'm not sure what this means, perhaps someone more clever will find it useful. @DTS Engineer
Topic: App & System Services SubTopic: iCloud Tags:
Aug ’24
Reply to EditMode & EditButton not working in a way I expect
We also have this issue. Feedback submitted some time ago under FB13201571. Editing works, as long as NavigationStack is not used. This works. struct ListSelectionTest: View { @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { VStack { EditButton() List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } The problem appears when the List is wrapped in NavigationStack. This only works when the EditButton is tapped TWICE. struct ListSelectionTest: View { @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { NavigationStack { VStack { EditButton() List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } } Replacing EditButton with a custom Button produces a different visual error. Editing is set correctly, but the multi-selection indicators quickly appear and then disappear again. struct ListSelectionTest: View { @Environment(\.editMode) private var editMode @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { NavigationStack { VStack { Button((editMode?.wrappedValue.isEditing ?? false) ? "Done" : "Edit") { editMode?.wrappedValue = (editMode?.wrappedValue.isEditing ?? false) ? .inactive : .active } List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } } In short, we suspect there is a SwiftUI bug related to triggering List editing when the list is in NavigationStack.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’23
Reply to SwiftData @Environment can't use bindings?
Same problem here. I'm struggling with extracting NavigationPath() into a separate class using @Observable. When this class is marked as @Observable, typing NavigationStack(path: viewModel.path) {...} results in error: Cannot convert value of type 'NavigationPath' to expected argument type 'Binding<NavigationPath>' Variations like $viewModel.path or viewModel.$path do not work either. The only "working" solution is: var body: some View { @Bindable var bindable = viewModel NavigationStack(path: $bindable.path) {...} } But this is very hacky.
Topic: App & System Services SubTopic: iCloud Tags:
Jul ’23
Reply to Cloudkit constraint issue
I struggled with this a year ago. In the end I restructured my model so it works without unique constraints. For example, you may have a many-to-many relationship between entities Color and Animal (an animal may have multiple colours, and vice-versa: a specific colour may be found on various animals). Without unique constraints, you can fetch animals by colour like this:     if colorFilter != .noValue {       // any animal where color in colors relationship contains value       predicates.append(NSPredicate(format: "ANY colors.color == %@", colorFilter.rawValue))     }
Topic: App & System Services SubTopic: iCloud Tags:
Feb ’23
Reply to CreateML image extraction ends in `Unexpected error`, opens `Create New Project` window
I tried to train the model programmatically in a Swift Playground. This process also failed and returned the following error (I have no idea what it means). Training on a smaller subset of the dataset succeeds. remoteProcessWasInterrupted Error: ["ThreadID": 1278902, "ThreadCrashed": 1, "StackFrameDictionaries": <__NSArrayM 0x600001fe0570>( {     StackFrameModule = vImage;     StackFramePC = 7223916652;     StackFrameSymbolName = "__ERROR_Buffer_Write__Too_Small_For_Arguments_To_vImage__CheckBacktrace"; }, {     StackFrameModule = vImage;     StackFramePC = 7223916524;     StackFrameSymbolName = "_vImageDebug_CheckDestBuffer"; }, {     StackFrameModule = vImage;     StackFramePC = 7223913756;     StackFrameSymbolName = "_vImageConvert_AnyToAny"; }, ... // more fields follow ) ]
Topic: Machine Learning & AI SubTopic: General Tags:
Jan ’23
Reply to SwiftData - Context missing for optional
I also tried changing the method of deletion to the following. This tries to delete entity Object that has a to-many relationship children: [Child]. guard let id = object.id else { return } do { try container.mainContext.delete(model: Object.self, where: #Predicate { object in object.id == id }) } catch { print(error) } This does not crash the app, but fails to delete the entity with the following console output: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={Reason=Entity named:Object not found for relationship named:children, MissingEntity=Object. (<NSEntityDescription: 0x6000035100b0>) ... I'm not sure what this means, perhaps someone more clever will find it useful. @DTS Engineer
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to SwiftData - Context missing for optional
I'm having the same issue. Things I tried (none of them worked): Remove .cascade delete rule Remove all children-type entities before removing the parent-type entity .swipeActions as well as .onDelete
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to SwiftData fatal error "Never access a full future backing data"
I'm having the same problem, specifically when attempting to delete a model instance. It seems to be an instance that existed prior to a change to the model properties. Instances created after the change to model properties are deleted ok, but this one has become "sticky".
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Swift Charts: Changing chartXVisibleDomain changes chartScrollPosition
Feedback submitted at FB14091989.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Swift Charts: .hour annotations do not appear
Feedback submitted at FB14091955.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Unable to login to iCloud on Simulator (to test SwiftData sync)
Same issue here. Have you been able to resolve this?
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to Using @Bindable with a Observable type
I'm having the same problem
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to SwiftUI List crash with @FetchRequest and @ObservedObject
Building on zulfishah's solution, just executing the button closure in an async context fixes the issue for me. Button(role: .destructive) { Task { deleteObject() } } label: { Label("Delete", systemImage: "trash.fill") }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to EditMode & EditButton not working in a way I expect
We also have this issue. Feedback submitted some time ago under FB13201571. Editing works, as long as NavigationStack is not used. This works. struct ListSelectionTest: View { @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { VStack { EditButton() List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } The problem appears when the List is wrapped in NavigationStack. This only works when the EditButton is tapped TWICE. struct ListSelectionTest: View { @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { NavigationStack { VStack { EditButton() List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } } Replacing EditButton with a custom Button produces a different visual error. Editing is set correctly, but the multi-selection indicators quickly appear and then disappear again. struct ListSelectionTest: View { @Environment(\.editMode) private var editMode @State var selection: Set<String> = [] let strings = ["One", "Two", "Three"] var body: some View { NavigationStack { VStack { Button((editMode?.wrappedValue.isEditing ?? false) ? "Done" : "Edit") { editMode?.wrappedValue = (editMode?.wrappedValue.isEditing ?? false) ? .inactive : .active } List(selection: $selection) { ForEach(strings, id: \.self) { string in Text(string).tag(string) } } } } } } In short, we suspect there is a SwiftUI bug related to triggering List editing when the list is in NavigationStack.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to SwiftData @Environment can't use bindings?
Same problem here. I'm struggling with extracting NavigationPath() into a separate class using @Observable. When this class is marked as @Observable, typing NavigationStack(path: viewModel.path) {...} results in error: Cannot convert value of type 'NavigationPath' to expected argument type 'Binding<NavigationPath>' Variations like $viewModel.path or viewModel.$path do not work either. The only "working" solution is: var body: some View { @Bindable var bindable = viewModel NavigationStack(path: $bindable.path) {...} } But this is very hacky.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to SwiftUI MapKit - MapAnnotation - Publishing changes from within view updates is not allowed, this will cause undefined behavior.
I still have this issue. When working with Map() and MapAnnotation(), I get swamped by console prints and purple warnings. Apple please provide a fix or advice!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Icon on left of Text in Label inside of Menu
same
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Cloudkit constraint issue
I struggled with this a year ago. In the end I restructured my model so it works without unique constraints. For example, you may have a many-to-many relationship between entities Color and Animal (an animal may have multiple colours, and vice-versa: a specific colour may be found on various animals). Without unique constraints, you can fetch animals by colour like this:     if colorFilter != .noValue {       // any animal where color in colors relationship contains value       predicates.append(NSPredicate(format: "ANY colors.color == %@", colorFilter.rawValue))     }
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to CreateML image extraction ends in `Unexpected error`, opens `Create New Project` window
I tried to train the model programmatically in a Swift Playground. This process also failed and returned the following error (I have no idea what it means). Training on a smaller subset of the dataset succeeds. remoteProcessWasInterrupted Error: ["ThreadID": 1278902, "ThreadCrashed": 1, "StackFrameDictionaries": <__NSArrayM 0x600001fe0570>( {     StackFrameModule = vImage;     StackFramePC = 7223916652;     StackFrameSymbolName = "__ERROR_Buffer_Write__Too_Small_For_Arguments_To_vImage__CheckBacktrace"; }, {     StackFrameModule = vImage;     StackFramePC = 7223916524;     StackFrameSymbolName = "_vImageDebug_CheckDestBuffer"; }, {     StackFrameModule = vImage;     StackFramePC = 7223913756;     StackFrameSymbolName = "_vImageConvert_AnyToAny"; }, ... // more fields follow ) ]
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to UICloudSharingController sharing via Messages broken in iOS16
This is now confirmed by Apple as a known bug with high priority. A detailed, up-to-date post is kept at SO: https://stackoverflow.com/questions/73888519/uicloudsharingcontroller-does-not-work-for-core-data-with-cloudkit
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22