Post

Replies

Boosts

Views

Activity

Reply to How to Fix Cracking and Popping Sound ?
This sound popping issues started happening with Xcode 12 and it has been months with no fix. Problem is that simulators (SwiftUi views are using them also) and the fact that phones do not have the same "sound" hardware a.k.k simulators actually change the output of the sound you hear in on your Mac (because they "simulate" it to show what the phone would do). Unfortunately this causes many many issues on the Mac sound hardware but is 100% fixable by the Xcode team, we cant do anything ourselves its a problem if the simulators "highjacking" the systems sounds and outputting it via a hardware that is not supposed to output this way. This is mind boggling that it is still not fixed.
Topic: App & System Services SubTopic: Core OS Tags:
Dec ’20
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