Post

Replies

Boosts

Views

Activity

Reply to Calling `requestAuthorization(options:completionHandler:)` in Swift 6 leads to `EXC_BAD_INSTRUCTION` crash.
I will add my initial solution as a comment so it can be marked as solution to the question. The only solution that I have found so far is to switch to using the async version of the requestAuthorization API: Task { let center = UNUserNotificationCenter.current() do { if try await center.requestAuthorization(options: [.alert, .sound, .badge]) == true { print("success") } else { print("fail") } } catch { print("Error") } }
Topic: UI Frameworks SubTopic: General Tags:
Oct ’24
Reply to In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
While waiting for some official statement why this is happening in iOS 18 and not iOS 17, I found a workaround to force a refresh of the managedObjectContext when changes are saved. Code sample: @Environment(\.managedObjectContext) private var managedObjectContext var body: some View { NavigationStack { Text("") } .onReceive(NotificationCenter.default.publisher(for: .NSManagedObjectContextDidSave)) { _ in DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { withAnimation { managedObjectContext.refreshAllObjects() } } } } It's not perfect but it gets the job done to update the list when any attributes are changed, not only those used as SortDescriptor. Hope this helps anyone facing this problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Reply to In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
Hi @DTS Engineer Thank for responding to my topic. Marking the object with ObservedObject does not resolve the issue, the change is still not propagated back to the list that uses SectionedFetchRequest. I created a runnable project from the Xcode templates that shows the issue. Clone this repo https://github.com/VladimirAmiorkov/SwiftUI-SectionedFetchRequest Open the Edit List Test.xcodeproj Run the project Press the "+" to add some items, notice the "Text- Init 0" Tap on the row to pen EditView Notice the "Text- Init 0" that is show inside EditView Tap on the button "Change text" Notice the "Text- Init 0 ..." that is show inside EditView changed Go back Notice the "Text- Init 0" in the List is not updated (issue happens here) Restart app Notice the "Text- Init 0" in the List is updated Same code works correct and updates the list if I switch from SectionedFetchRequest to FetchRequest. You can uncomment it in the project. Or it also works if I add SortDescriptor(\.text) to the SectionedFetchRequest but that is not what I want as I do not want to list all "edible" entities of the object in the request. Thank you for looking into this.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to `Text` (Label) text color issue during app resuming from suspended (changes from black to light or vice versa, depending on current appearance mode).
@Claude31 , Yes of course but it is pure SwiftUI from template. struct ContentView: View { private var tabSelection: Binding<String> { Binding( get: { selectedTab }, set: { selectedTab = $0 } )} @State private var selectedTab: String = "Test" var body: some View { TabView(selection: tabSelection, content: { NavigationStack { List { ForEach(0...1000, id: \.self) { index in Text("Test 1 - Row: \(index)") } } .navigationTitle("Test 1") } .listStyle(.insetGrouped) .tabItem { Image(systemName: "sun") Text("Test") } .tag("Test") }) .tabViewStyle(.sidebarAdaptable) } }
Topic: UI Frameworks SubTopic: SwiftUI
Jan ’25
Reply to No insert animation after `insert` when using SwiftData.
@DTS Engineer Thank for the reply. Yes this work and there is now animation when I change the Query animation. Very strange that the Xcode template does not show this out of the box and shows the not working and unnecessary withAnimation block in the add function. But now I have a slightly different problem, again with no animation after insert. If I save the modelContext the animation now is gone: @Query(animation: .default) private var items: [Item] ... private func addItem() { let newItem = Item(timestamp: Date()) modelContext.insert(newItem) do { try modelContext.save() } catch { } } How can someone achieve an insert and save + animation?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’25
Reply to SwiftUI: Navigation title overlapping content of `TabView` after "tap to scroll to the top" on `tabItem`
Hi @DTS Engineer , I have it a try with both values but the issue persists. I have submitted an issue feedback report with ID: FB16430659 Currently the only way to fix this is to change the way the navigation title is displayed by adding .navigationBarTitleDisplayMode(.inline) but that changes the entire UI/UX by moving the title to the nav bar.
Topic: UI Frameworks SubTopic: SwiftUI
Jan ’25
Reply to `Text` (Label) text color issue during app resuming from suspended (changes from black to light or vice versa, depending on current appearance mode).
@Claude31 Some more info on this. I think it happens during "CoreData" processing (insert/deleted + save) while the application is not active (in the background) Example 1: If I process userNotificationCenter(_:didReceive:withCompletionHandler:) and interact with CoreData's manage view context to insert a new object. Example 2: Processing HealthKit APIs to once again interact with CoreData's view context. For example observing a long running HKAnchoredObjectQuery.
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’25
Reply to How to delete container in CloudKit Dashboard?
Lol really you cannot delete? Wooow man this is incredible and I just started with CloudKit to find out this basic functionality not working hahahah.
Replies
Boosts
Views
Activity
Jun ’21
Reply to Xcode 14: Publishing changes from within view updates
I send feedback to Apple and received answer to retest this with iOS 16.2. After retesting this is not longer shown as a warning so it looks like Apple has fixed it behind the scenes.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Building documentation (Docc) gives error coming from `FirebaseCoreExtension` while building with Xcode 16
I have reported this issue to Firebase and they are working on a solution for next version. https://github.com/firebase/firebase-ios-sdk/issues/13756
Replies
Boosts
Views
Activity
Oct ’24
Reply to Calling `requestAuthorization(options:completionHandler:)` in Swift 6 leads to `EXC_BAD_INSTRUCTION` crash.
I will add my initial solution as a comment so it can be marked as solution to the question. The only solution that I have found so far is to switch to using the async version of the requestAuthorization API: Task { let center = UNUserNotificationCenter.current() do { if try await center.requestAuthorization(options: [.alert, .sound, .badge]) == true { print("success") } else { print("fail") } } catch { print("Error") } }
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
While waiting for some official statement why this is happening in iOS 18 and not iOS 17, I found a workaround to force a refresh of the managedObjectContext when changes are saved. Code sample: @Environment(\.managedObjectContext) private var managedObjectContext var body: some View { NavigationStack { Text("") } .onReceive(NotificationCenter.default.publisher(for: .NSManagedObjectContextDidSave)) { _ in DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { withAnimation { managedObjectContext.refreshAllObjects() } } } } It's not perfect but it gets the job done to update the list when any attributes are changed, not only those used as SortDescriptor. Hope this helps anyone facing this problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
Hi @DTS Engineer Thank for responding to my topic. Marking the object with ObservedObject does not resolve the issue, the change is still not propagated back to the list that uses SectionedFetchRequest. I created a runnable project from the Xcode templates that shows the issue. Clone this repo https://github.com/VladimirAmiorkov/SwiftUI-SectionedFetchRequest Open the Edit List Test.xcodeproj Run the project Press the "+" to add some items, notice the "Text- Init 0" Tap on the row to pen EditView Notice the "Text- Init 0" that is show inside EditView Tap on the button "Change text" Notice the "Text- Init 0 ..." that is show inside EditView changed Go back Notice the "Text- Init 0" in the List is not updated (issue happens here) Restart app Notice the "Text- Init 0" in the List is updated Same code works correct and updates the list if I switch from SectionedFetchRequest to FetchRequest. You can uncomment it in the project. Or it also works if I add SortDescriptor(\.text) to the SectionedFetchRequest but that is not what I want as I do not want to list all "edible" entities of the object in the request. Thank you for looking into this.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Updates to data from App Intent don't trigger view refresh in app
You should annotate the perform() function of the intent with @MainActor, that way the UI updates. Here is a comment from Apple own example: /** When the system runs the intent, it calls `perform()`. Intents run on an arbitrary queue. Intents that manipulate UI need to annotate `perform()` with `@MainActor` so that the UI operations run on the main actor. */
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to AppIntent with long-running perform()
Hi @brenner_scott_980 , You should take a look at ForegroundContinuableIntent, this is a special intent that can be useful for log running tasks.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to In SwiftUI in iOS 18.1, `SectionedFetchRequest` is not refreshed when changes are done to the fetched entity's attributes.
@DTS Engineer Did you see my comment above, is there anything else you need from me regarding this issue investigation?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to `Text` (Label) text color issue during app resuming from suspended (changes from black to light or vice versa, depending on current appearance mode).
@Claude31 , Yes of course but it is pure SwiftUI from template. struct ContentView: View { private var tabSelection: Binding<String> { Binding( get: { selectedTab }, set: { selectedTab = $0 } )} @State private var selectedTab: String = "Test" var body: some View { TabView(selection: tabSelection, content: { NavigationStack { List { ForEach(0...1000, id: \.self) { index in Text("Test 1 - Row: \(index)") } } .navigationTitle("Test 1") } .listStyle(.insetGrouped) .tabItem { Image(systemName: "sun") Text("Test") } .tag("Test") }) .tabViewStyle(.sidebarAdaptable) } }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’25
Reply to No insert animation after `insert` when using SwiftData.
@DTS Engineer Thank for the reply. Yes this work and there is now animation when I change the Query animation. Very strange that the Xcode template does not show this out of the box and shows the not working and unnecessary withAnimation block in the add function. But now I have a slightly different problem, again with no animation after insert. If I save the modelContext the animation now is gone: @Query(animation: .default) private var items: [Item] ... private func addItem() { let newItem = Item(timestamp: Date()) modelContext.insert(newItem) do { try modelContext.save() } catch { } } How can someone achieve an insert and save + animation?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to No insert animation after `insert` when using SwiftData.
@DTS Engineer Thank you. I have submitted feedback with report ID FB16426138
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to SwiftUI: No voice input icon in field when using `searchable`
Hi @DTS Engineer , Thank for the response. I have submitted feedback with ID: FB16430866
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’25
Reply to SwiftUI: Navigation title overlapping content of `TabView` after "tap to scroll to the top" on `tabItem`
Hi @DTS Engineer , I have it a try with both values but the issue persists. I have submitted an issue feedback report with ID: FB16430659 Currently the only way to fix this is to change the way the navigation title is displayed by adding .navigationBarTitleDisplayMode(.inline) but that changes the entire UI/UX by moving the title to the nav bar.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Jan ’25
Reply to `Text` (Label) text color issue during app resuming from suspended (changes from black to light or vice versa, depending on current appearance mode).
@Claude31 Some more info on this. I think it happens during "CoreData" processing (insert/deleted + save) while the application is not active (in the background) Example 1: If I process userNotificationCenter(_:didReceive:withCompletionHandler:) and interact with CoreData's manage view context to insert a new object. Example 2: Processing HealthKit APIs to once again interact with CoreData's view context. For example observing a long running HKAnchoredObjectQuery.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’25