Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

Lack of API to access scrubber preview time in AVPlayerViewController (scrubbingTime)
Hi everyone, I'm working with AVPlayerViewController in a tvOS/iOS app and ran into a limitation that I believe some developers face. When using player.currentItem?.currentTime(), we only get the playback time—which is fine while the video is playing. But when the player is paused and the user drags the scrubber, there's no public API to get the time that is currently being previewed under the scrubber thumb (stick), but there's no way to read it programmatically. This becomes a problem when trying to show thumbnail previews or display metadata tied to the scrubbed position.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
1
102
Jun ’25
SwiftUI 26: How to change new toggles background color?
The .tint modifier doesn't seem to change the background color on the redesigned macOS 26 toggles. For example, using: Toggle("", isOn: isOn) .toggleStyle(.switch) .tint(.cyan) .scaleEffect(0.8) .opacity(isEnabled ? 1.0 : 0.4) the toggles use the system accent color instead of cyan. Has SwiftUI introduced a new modifier for that? I couldn't find anything in the June 2025 changes.
0
0
180
Sep ’25
zoom navigationTransition breaks navigation title
When combining a zoom navigationTransition with a List in a NavigationStack we end up getting the navigationTitle not properly re-positioning itself on dismiss/back. It looks like a visual bug/glitch (unless I missed something). This seems to not happen with a ScrollView import SwiftUI struct Item: Identifiable { let id: UUID = UUID() } struct ContentView: View { @State private var selected: Item? @Namespace private var animation var body: some View { NavigationStack { List { ForEach((0..<50).map { _ in Item() }, id: \.id) { item in Button { selected = item } label: { Text(item.id.uuidString) .frame(maxWidth: .infinity, alignment: .leading) } .matchedTransitionSource(id: item.id, in: animation) } } .navigationTitle("Title") .navigationSubtitle("Subtitle") } .fullScreenCover(item: $selected) { item in Text(item.id.uuidString) .frame(maxWidth: .infinity) .navigationTransition(.zoom(sourceID: item.id, in: animation)) } } } #Preview { ContentView() }
Topic: UI Frameworks SubTopic: SwiftUI
0
1
110
Sep ’25
How to intercept or prevent user input in SwiftUI TextField when embedding in UIKit
Hi all, I’m working on a UIKit app where I embed a SwiftUI TextField using UIHostingController. I’m using an ObservableObject model to drive the textfield content: class TextFieldModel: ObservableObject { @Published var text: String @Published var placeholder: String @Published var isSecure: Bool @Published var isFocused: Bool init(pText: String, pPlaceholder: String, pIsSecure: Bool, pIsFocused: Bool) { self.text = pText self.placeholder = pPlaceholder self.isSecure = pIsSecure self.isFocused = pIsFocused } } And my SwiftUI view: struct TextFieldUI: View { @ObservedObject var pModel: TextFieldModel @FocusState private var pIsFocusedState: Bool var body: some View { TextField(pModel.placeholder, text: $pModel.text) .focused($pIsFocusedState) } } I embed it in UIKit like this: let swiftUIContentView = TextFieldUI(pModel: model) let hostingController = UIHostingController(rootView: swiftUIContentView) addChild(hostingController) view.addSubview(hostingController.view) hostingController.didMove(toParent: self) Question: In UIKit, if I subclass UITextField, I can override insertText(_:) and choose not to call super, effectively preventing the textfield from updating when the user types. Is there a SwiftUI equivalent to intercept and optionally prevent user input in a TextField, especially when it’s embedded inside UIKit? What is the recommended approach in SwiftUI for this?
0
0
129
Sep ’25
How to customize item transitions inside a Picker View?
I have a simple Picker where the options available change by the view state. I would like to have the transition animated but the default animation is not good so I tried setting a .transition() and or an .animation() inside an item on the picker but it is ignored. The same happens if the transition is set on the picker itself since it's always present. Am I doing it right and is just not posible or is there something else to do? Code to reproduce the issue: struct ContentView: View { @State var list: [String] = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] @State var selected: String? @State var toggle: Bool = false var body: some View { VStack { Picker("List", selection: $selected) { ForEach(list, id: \.self) { Text($0).tag($0) // .transition(.opacity) } } .pickerStyle(.segmented) // .transition(.opacity) HStack { Button(action: swapOptions) { Text("Swap") } } } .padding() } } extension ContentView { func swapOptions() { withAnimation { toggle.toggle() switch toggle { case true: list = [ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", ] case false: list = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] } } } } ``
Topic: UI Frameworks SubTopic: SwiftUI
0
0
98
May ’25
Nested NavigationSplitView has unexpected layout shift inside a TabView
I have initialized a new SwiftUI project for iOS. I wrapped the default NavigationSplitView from SwiftData inside a TabView and ran into the following issue: On an iPad (Air, 13 inch, iPadOs 26), the button to open/close the sidebar shifts downwards while opening or closing the sidebar. When the animation finishes, the button jumps back to the original position. Here's the code I used inside my ContentView: var body: some View { TabView { Tab("Kategorien", systemImage: "circle.fill") { NavigationSplitView { List { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } .onDelete(perform: deleteItems) } .toolbar { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } } detail: { Text("Select an item") } } Tab("Alle Bücher", systemImage: "circle.fill") { Text("Alle Bücher") } } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
71
Sep ’25
Record microphone in a Keyboard app (in the background)
I'm currently I'm working on an iOS app + custom keyboard extension, and I’m hoping to get some insight into how to best architect a workflow where the keyboard acts as a remote trigger for dictation, but the main app handles the actual microphone recording and transcription. I know that third-party keyboards are sandboxed and can’t access the microphone directly, so the pattern I’m following is similar to what Wispr Flow appears to be doing: What I'm Trying to Build The user taps a mic button in the custom keyboard (installed system-wide). This triggers the main app to open, start a recording session, and send the audio to my transcription endpoint (not using Speech.framework). Once the transcription result is ready, it's stored in an App Group shared container. The keyboard extension polls for or receives the transcribed text and inserts it into the current input field via textDocumentProxy.insertText(...). Key Questions Triggering App Dictation from Keyboard Is there a clean system-native way to transition from the keyboard to the main app and back? Are there best practices around?: Preventing jarring transitions (keyboard disappearing)? Letting the app record in the background once triggered (see below)? Keeping the App Alive During Audio Recording Once the main app is opened to handle the dictation: I want it to record audio continuously (sometimes for up to a minute or 2 ), send it to an external transcription API, and return the result. However, from what I have read, iOS aggressively suspends or kills apps that are not in the foreground or haven’t requested the correct background modes - especially if there are background tasks running for longer than 30 seconds. Even with audio enabled in Background Modes and a live AVAudioEngine session, I find that the app is sometimes paused or killed after a few seconds; especially when the user switches back to the app where they want to type. But apps like Wispr Flow seem to manage this well. Their flow allows the user to record voice and insert it seamlessly without the app being terminated mid-recording. So: ✅ How do I prevent my app from being killed/suspended while it's recording, especially when the user switches back to the original app? Do I need: A background AVAudioSession hack? Audio playback tricks (e.g. silent audio)? A workaround using CallKit (some apps seem to use it for persistent audio sessions)? Something else Apple allows but doesn’t document clearly (or I am just a bad sercher)? Returning Text to the Keyboard Extension I’m using UserDefaults(suiteName:) in the App Group to pass the transcription result. Is that still the recommended approach? Would it be better to use a shared file (for larger data or richer metadata)? Are there any timing issues I should be aware of, e.g. like race conditions, stale reads, etc.?
0
0
204
Sep ’25
SwiftUI crash on OSX 26 using NSColorPanel
Crashlog-0916-071225.log I have an app that crashes on OSX 26 only. I have a @StateObject which is an observer of the NSColorPanel. When I call let panel = NSColorPanel.shared in init(), SwiftUI will crash - apparently with an update while view is being updated. See crash log. I was able to work around it by adding let _ = NSColorPanel.shared in my AppDelegate before SwiftUI is initialized. The exact code worked fine in all previous OSX versions.
0
0
109
Sep ’25
How to determine which ui control is found first in the view hierarchy, when I assign the same keyboardShortcut () to 2 buttons?
import SwiftUI struct ContentView: View { var body: some View { VStack { Button ("Button 1") { print ("Button 1"); } .keyboardShortcut("k", modifiers: .command) Button ("Button 2") { print ("Button 2"); } .keyboardShortcut("k", modifiers: .command) } } } I the above snippet, I have assigned the same keyboard shortcut (cmd +k) to 2 different buttons. According to the docs, if multiple controls are associated with the same shortcut, the first one found is used. How do I figure out if Button 1 would be found first during the traversal or Button 2 ? Is it based on the order of declaration? Is it always the case that Button 1 would be found first since it was declared before Button 2 ?
0
0
123
Mar ’25
SwiftUI Nav Bar Changes in Height When Loading While Presented in a Sheet
If you create a SwiftUI App where a ‘.sheet’ is presented and use a NavigationStack within that Sheet, when you use NavigationLink to present a view, the title of the Nav Bar will start at a height of 46px and pop to the Default Height of 54px when it loads causing a visual pop in the UI. In iOS 18 it functions correctly, in iOS 26 the visual pop is present. This impacts both inline and large styles, if you disable the back button it is still present, the only way I have discovered to get rid of it is by using 'fullScreenCover' instead of '.sheet'. This feels like buggy UI. This issue has been present since iOS 26 Beta 5, I was hoping it would be fixed but is still present in the GM. Feedback has been filed via Feedback Assistant: FB20228369 This is the code to re-produce the issue: import SwiftUI struct ContentView: View { @State private var showSheet: Bool = false var body: some View { VStack { Button { showSheet.toggle() } label: { Text("Show Sheet") } } .padding() .sheet(isPresented: $showSheet) { NavigationStack { List { NavigationLink { Rectangle() .foregroundStyle(.red) .navigationTitle("Red") } label: { Text("Show Red") } } } .presentationSizing(.page) } } } #Preview { ContentView() }
0
1
321
Sep ’25
searchable isPresented set too late in a sheet
I have a popover/sheet in iOS which allows users to search and add items to a list. When the sheet is shown, the search should always be active. I am using searchable on a NavigationStack inside the sheet. I am using the isPresented parameter to activate search. My issue is with the animation of the search activation. Even if I use... isPresented: .constant(true) ...the search isn't activated until the sheet has completed it's entrance animation, resulting in two stages of animation. I can't add a video here, but the two images below show the steps I am seeing. First a slide up animation, with the search in the navigation drawer, then a second animation, once the sheet is fully in place, as the search becomes active. Is it possible to merge these two animations, so search is in place when the sheet animates up?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
53
Apr ’25
[Want] A View detects one from multiple custom Gestures.
SwiftUI Gesture cannot detect one of multiple gestures. I made a library for it because no default functions for it exists and I need it for my app. https://github.com/Saw-000/SwiftUI-DetectGestureUtil I want to use a function like this library with "import SwiftUI". The function is needed in the core maybe, isn't it?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
128
Nov ’25
Why does SwiftUI Text(date, style: .relative) show the same duration for different dates?
I’m using SwiftUI’s Text(_:style:) with the .relative style to show how long ago a date occurred. According to the docs: A style displaying a date as relative to now. I expected it to show the precise difference between a past date and the current date. However, I noticed that two dates that are 3 days apart both display the same relative string under certain conditions. Code snippet to reproduce- (using GMT time zone and the system calendar) IMPORTANT: To reproduce this, set your Mac’s system clock to 8 September 2025, 3:00 AM. SwiftUI’s relative style uses the current system time as its reference point, so changing the clock is necessary to see the behavior. Settings Mac is set to Central European Time zone (but this behaviour was also reproduced by one of my app's users in the US.) Mac OS Sequoia 15.5 XCode 16.4 tested on an iOS Simulator and a real iPhone both running iOS 18.5 struct TestDateView: View { var body: some View { // 8. July 10AM to 8. September 3AM = Shows 2 months 2 days let startDate1: Date = Calendar.current.date(from: .init(calendar: .current, timeZone: .gmt, year: 2025, month: 7, day: 8, hour: 10, minute: 0, second: 0))! // 5. July 10AM to 8. September 3AM = Shows 2 months 2 days let startDate2: Date = Calendar.current.date(from: .init(calendar: .current, timeZone: .gmt, year: 2025, month: 7, day: 5, hour: 10, minute: 0, second: 0))! // IMPORTANT!: Need to set MAC's clock to 8. September 3:00 AM to reproduce this bug VStack { Text(startDate1, style: .relative) Text(startDate2, style: .relative) } } } How exactly does the .relative style work internally? Is it expected that different dates can collapse into the same result like this, or is there a better way to use .relative to get more precise results? PS: I know about DateComponents and DateFormatter for exact calculations, but I’d like to understand this approach since it auto-updates natively with no timers or publishers.
0
0
107
Sep ’25
SwiftUI DocumentGroup blocks "Create Document" button when opening a document in conflict state
In a SwiftUI DocumentGroup, the "Create Document" button remains permanently disabled when attempting to open a document that is in a conflict state (e.g., due to simultaneous edits across devices). As a result, the user cannot create new documents, and the app becomes stuck. On macOS, the expected conflict resolution dialog appears, and the app continues to function normally. On iOS, however, the "Create Document" button stays disabled indefinitely. This behavior occurs consistently in a default SwiftUI document-based app. Steps to Reproduce: Create a new SwiftUI document-based project in Xcode; Setup iCloud Storage in Signing & Capabilities; Create an empty document and place it in a conflict state (e.g., save it simultaneously from two devices); Attempt to open the conflicted document on an iPhone or iPad; Expected Result: The user should be able to resolve the conflict and continue working; The "Create Document" button should remain functional; Actual Result: The "Create Document" button is disabled permanently; The app cannot create new documents until restarted; Environment; iOS 18, iOS 26 (latest tested); Xcode Version 16.4 (16F6) Reproduced on iPhone and iPad; Works as expected on macOS; This appears to be a blocking issue in SwiftUI’s DocumentGroup on iOS. FB20203775
0
0
139
Sep ’25
Alert Closures Not Firing + Navigation Animations Broken
Hi, I hope you are doing well. We have been running up against an issue in our application which despite our best efforts we cannot seem to solve. After a certain point of use (of which we cannot seem to isolate a trigger), something internally with the way SwiftUI handles animation transactions seems to be breaking. This results in the following behavior that we (and our users) are noticing: Alerts/Sheets/NavigationPath changes lose all animations Closures associated with buttons no longer fire at all. The alert disappears, but with no animation and any action associated with the button selected does nothing. This results in an infinite loop of triggering an alert, clicking on an alert action, and the alert dismissing without the corresponding action ever occurring. We have tried moving the navigationPath out of a view model (Observable) and into a @State variable on the view in case it was an issue with view pre-rendering due to path changes, but this did not improve our case. We hoisted the state and the alert presentation out of all subviews and onto the root view of our navigation destination (as this happens on a sub-page of the application) as well, and while did this seem to minimize occurrences it did not fully resolve it. The app structure of our watch app is as follows: We have a NavigationStack at the root level which wraps a TabView, containing 3 pages. Selecting a button triggers a navigation destination, presenting a detail view. The detail view is a ZStack which switches on a property contained in an @State Observable view model scoped to the detail view. The ZStack can contain one of 5 subviews, derived from a viewState enum with associated values (all of which are equatable, and by extension viewState is also an equatable type as well). One of the subviews receives a binding, which on button trigger updates the binding and thus the view containing the ZStack presents the alert. Sometimes, when this happens, the animations break, and then are subsequently broken for the remainder of the lifetime of the app until it is force-closed (not backgrounded, but a full force-close). NavigationStack { TabView { Tab1 Tab2 // triggers navigationDestination Tab3 } .navigationDestination(for:) { DestinationView() // the view containing the ZStack + Alert } } STEPS TO REPRODUCE Unfortunately we have not been able to ascertain exactly what is causing this issue as we cannot reproduce it in a sandbox environment, only when moving through the view flow associated with our code. Any debugging ideas or recommendations would be greatly appreciated, as we have already tried _printChanges and do not notice any erroneous view redraws.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
84
Sep ’25
SwiftUI List optional refreshable
Currently refreshable modifier does not support nil as a value and there's no way of disabling refreshable without recreating the whole view. There are a few posts showing how refreshable could be optionally disabled on scrollViews using: \EnvironmentValues.refresh as? WritableKeyPath<EnvironmentValues, RefreshAction?> https://stackoverflow.com/a/77587703 However, this approach doesn't seem to work with Lists. Has anyone find any solutions for this?
0
0
172
Sep ’25
Modelactors, Repository and bootloader
In iOS 26, should we have bootloader that runs the repo on startup - or should we have that inside tasks in root view? we have repos that runs as a «closed» functions, we dont throw but updates swiftdata and we use @query in the views. So what is best? and for the repo we should have a repo that runs the upserts manage relations eg? Should that run on a modelactor?
0
0
221
Sep ’25
.preferredColorScheme doesn't work with .scrollEdgeEffectStyle(.hard, for: .top)
.preferredColorScheme(.dark) doesn't seem to affect app toolbar, when .scrollEdgeEffectStyle(.hard, for: .top) is used. In the attachment, you can see the title and toolbar items don't change according to current value of .preferredColorScheme (you may need to scroll a bit to achieve it) iOS 26 RC Feedback ID - FB19769073 import SwiftUI struct ContentView: View { var body: some View { NavigationStack { ScrollView(.vertical) { ForEach(0..<100) { index in Text("\(index)") .padding() .border(.blue) .background(.blue) .frame(maxWidth: .infinity) } } .scrollEdgeEffectStyle(.hard, for: .top) .navigationTitle("Test Title") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: { }) { Text("Test") } } } } .preferredColorScheme(.dark) } } #Preview { ContentView() }
0
0
106
Sep ’25
Lack of API to access scrubber preview time in AVPlayerViewController (scrubbingTime)
Hi everyone, I'm working with AVPlayerViewController in a tvOS/iOS app and ran into a limitation that I believe some developers face. When using player.currentItem?.currentTime(), we only get the playback time—which is fine while the video is playing. But when the player is paused and the user drags the scrubber, there's no public API to get the time that is currently being previewed under the scrubber thumb (stick), but there's no way to read it programmatically. This becomes a problem when trying to show thumbnail previews or display metadata tied to the scrubbed position.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
1
Views
102
Activity
Jun ’25
SwiftUI 26: How to change new toggles background color?
The .tint modifier doesn't seem to change the background color on the redesigned macOS 26 toggles. For example, using: Toggle("", isOn: isOn) .toggleStyle(.switch) .tint(.cyan) .scaleEffect(0.8) .opacity(isEnabled ? 1.0 : 0.4) the toggles use the system accent color instead of cyan. Has SwiftUI introduced a new modifier for that? I couldn't find anything in the June 2025 changes.
Replies
0
Boosts
0
Views
180
Activity
Sep ’25
zoom navigationTransition breaks navigation title
When combining a zoom navigationTransition with a List in a NavigationStack we end up getting the navigationTitle not properly re-positioning itself on dismiss/back. It looks like a visual bug/glitch (unless I missed something). This seems to not happen with a ScrollView import SwiftUI struct Item: Identifiable { let id: UUID = UUID() } struct ContentView: View { @State private var selected: Item? @Namespace private var animation var body: some View { NavigationStack { List { ForEach((0..<50).map { _ in Item() }, id: \.id) { item in Button { selected = item } label: { Text(item.id.uuidString) .frame(maxWidth: .infinity, alignment: .leading) } .matchedTransitionSource(id: item.id, in: animation) } } .navigationTitle("Title") .navigationSubtitle("Subtitle") } .fullScreenCover(item: $selected) { item in Text(item.id.uuidString) .frame(maxWidth: .infinity) .navigationTransition(.zoom(sourceID: item.id, in: animation)) } } } #Preview { ContentView() }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
1
Views
110
Activity
Sep ’25
How to intercept or prevent user input in SwiftUI TextField when embedding in UIKit
Hi all, I’m working on a UIKit app where I embed a SwiftUI TextField using UIHostingController. I’m using an ObservableObject model to drive the textfield content: class TextFieldModel: ObservableObject { @Published var text: String @Published var placeholder: String @Published var isSecure: Bool @Published var isFocused: Bool init(pText: String, pPlaceholder: String, pIsSecure: Bool, pIsFocused: Bool) { self.text = pText self.placeholder = pPlaceholder self.isSecure = pIsSecure self.isFocused = pIsFocused } } And my SwiftUI view: struct TextFieldUI: View { @ObservedObject var pModel: TextFieldModel @FocusState private var pIsFocusedState: Bool var body: some View { TextField(pModel.placeholder, text: $pModel.text) .focused($pIsFocusedState) } } I embed it in UIKit like this: let swiftUIContentView = TextFieldUI(pModel: model) let hostingController = UIHostingController(rootView: swiftUIContentView) addChild(hostingController) view.addSubview(hostingController.view) hostingController.didMove(toParent: self) Question: In UIKit, if I subclass UITextField, I can override insertText(_:) and choose not to call super, effectively preventing the textfield from updating when the user types. Is there a SwiftUI equivalent to intercept and optionally prevent user input in a TextField, especially when it’s embedded inside UIKit? What is the recommended approach in SwiftUI for this?
Replies
0
Boosts
0
Views
129
Activity
Sep ’25
How to customize item transitions inside a Picker View?
I have a simple Picker where the options available change by the view state. I would like to have the transition animated but the default animation is not good so I tried setting a .transition() and or an .animation() inside an item on the picker but it is ignored. The same happens if the transition is set on the picker itself since it's always present. Am I doing it right and is just not posible or is there something else to do? Code to reproduce the issue: struct ContentView: View { @State var list: [String] = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] @State var selected: String? @State var toggle: Bool = false var body: some View { VStack { Picker("List", selection: $selected) { ForEach(list, id: \.self) { Text($0).tag($0) // .transition(.opacity) } } .pickerStyle(.segmented) // .transition(.opacity) HStack { Button(action: swapOptions) { Text("Swap") } } } .padding() } } extension ContentView { func swapOptions() { withAnimation { toggle.toggle() switch toggle { case true: list = [ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", ] case false: list = [ "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", ] } } } } ``
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
98
Activity
May ’25
Nested NavigationSplitView has unexpected layout shift inside a TabView
I have initialized a new SwiftUI project for iOS. I wrapped the default NavigationSplitView from SwiftData inside a TabView and ran into the following issue: On an iPad (Air, 13 inch, iPadOs 26), the button to open/close the sidebar shifts downwards while opening or closing the sidebar. When the animation finishes, the button jumps back to the original position. Here's the code I used inside my ContentView: var body: some View { TabView { Tab("Kategorien", systemImage: "circle.fill") { NavigationSplitView { List { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } .onDelete(perform: deleteItems) } .toolbar { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } } detail: { Text("Select an item") } } Tab("Alle Bücher", systemImage: "circle.fill") { Text("Alle Bücher") } } }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
71
Activity
Sep ’25
Record microphone in a Keyboard app (in the background)
I'm currently I'm working on an iOS app + custom keyboard extension, and I’m hoping to get some insight into how to best architect a workflow where the keyboard acts as a remote trigger for dictation, but the main app handles the actual microphone recording and transcription. I know that third-party keyboards are sandboxed and can’t access the microphone directly, so the pattern I’m following is similar to what Wispr Flow appears to be doing: What I'm Trying to Build The user taps a mic button in the custom keyboard (installed system-wide). This triggers the main app to open, start a recording session, and send the audio to my transcription endpoint (not using Speech.framework). Once the transcription result is ready, it's stored in an App Group shared container. The keyboard extension polls for or receives the transcribed text and inserts it into the current input field via textDocumentProxy.insertText(...). Key Questions Triggering App Dictation from Keyboard Is there a clean system-native way to transition from the keyboard to the main app and back? Are there best practices around?: Preventing jarring transitions (keyboard disappearing)? Letting the app record in the background once triggered (see below)? Keeping the App Alive During Audio Recording Once the main app is opened to handle the dictation: I want it to record audio continuously (sometimes for up to a minute or 2 ), send it to an external transcription API, and return the result. However, from what I have read, iOS aggressively suspends or kills apps that are not in the foreground or haven’t requested the correct background modes - especially if there are background tasks running for longer than 30 seconds. Even with audio enabled in Background Modes and a live AVAudioEngine session, I find that the app is sometimes paused or killed after a few seconds; especially when the user switches back to the app where they want to type. But apps like Wispr Flow seem to manage this well. Their flow allows the user to record voice and insert it seamlessly without the app being terminated mid-recording. So: ✅ How do I prevent my app from being killed/suspended while it's recording, especially when the user switches back to the original app? Do I need: A background AVAudioSession hack? Audio playback tricks (e.g. silent audio)? A workaround using CallKit (some apps seem to use it for persistent audio sessions)? Something else Apple allows but doesn’t document clearly (or I am just a bad sercher)? Returning Text to the Keyboard Extension I’m using UserDefaults(suiteName:) in the App Group to pass the transcription result. Is that still the recommended approach? Would it be better to use a shared file (for larger data or richer metadata)? Are there any timing issues I should be aware of, e.g. like race conditions, stale reads, etc.?
Replies
0
Boosts
0
Views
204
Activity
Sep ’25
SwiftUI crash on OSX 26 using NSColorPanel
Crashlog-0916-071225.log I have an app that crashes on OSX 26 only. I have a @StateObject which is an observer of the NSColorPanel. When I call let panel = NSColorPanel.shared in init(), SwiftUI will crash - apparently with an update while view is being updated. See crash log. I was able to work around it by adding let _ = NSColorPanel.shared in my AppDelegate before SwiftUI is initialized. The exact code worked fine in all previous OSX versions.
Replies
0
Boosts
0
Views
109
Activity
Sep ’25
How to determine which ui control is found first in the view hierarchy, when I assign the same keyboardShortcut () to 2 buttons?
import SwiftUI struct ContentView: View { var body: some View { VStack { Button ("Button 1") { print ("Button 1"); } .keyboardShortcut("k", modifiers: .command) Button ("Button 2") { print ("Button 2"); } .keyboardShortcut("k", modifiers: .command) } } } I the above snippet, I have assigned the same keyboard shortcut (cmd +k) to 2 different buttons. According to the docs, if multiple controls are associated with the same shortcut, the first one found is used. How do I figure out if Button 1 would be found first during the traversal or Button 2 ? Is it based on the order of declaration? Is it always the case that Button 1 would be found first since it was declared before Button 2 ?
Replies
0
Boosts
0
Views
123
Activity
Mar ’25
SwiftUI Nav Bar Changes in Height When Loading While Presented in a Sheet
If you create a SwiftUI App where a ‘.sheet’ is presented and use a NavigationStack within that Sheet, when you use NavigationLink to present a view, the title of the Nav Bar will start at a height of 46px and pop to the Default Height of 54px when it loads causing a visual pop in the UI. In iOS 18 it functions correctly, in iOS 26 the visual pop is present. This impacts both inline and large styles, if you disable the back button it is still present, the only way I have discovered to get rid of it is by using 'fullScreenCover' instead of '.sheet'. This feels like buggy UI. This issue has been present since iOS 26 Beta 5, I was hoping it would be fixed but is still present in the GM. Feedback has been filed via Feedback Assistant: FB20228369 This is the code to re-produce the issue: import SwiftUI struct ContentView: View { @State private var showSheet: Bool = false var body: some View { VStack { Button { showSheet.toggle() } label: { Text("Show Sheet") } } .padding() .sheet(isPresented: $showSheet) { NavigationStack { List { NavigationLink { Rectangle() .foregroundStyle(.red) .navigationTitle("Red") } label: { Text("Show Red") } } } .presentationSizing(.page) } } } #Preview { ContentView() }
Replies
0
Boosts
1
Views
321
Activity
Sep ’25
searchable isPresented set too late in a sheet
I have a popover/sheet in iOS which allows users to search and add items to a list. When the sheet is shown, the search should always be active. I am using searchable on a NavigationStack inside the sheet. I am using the isPresented parameter to activate search. My issue is with the animation of the search activation. Even if I use... isPresented: .constant(true) ...the search isn't activated until the sheet has completed it's entrance animation, resulting in two stages of animation. I can't add a video here, but the two images below show the steps I am seeing. First a slide up animation, with the search in the navigation drawer, then a second animation, once the sheet is fully in place, as the search becomes active. Is it possible to merge these two animations, so search is in place when the sheet animates up?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
53
Activity
Apr ’25
[Want] A View detects one from multiple custom Gestures.
SwiftUI Gesture cannot detect one of multiple gestures. I made a library for it because no default functions for it exists and I need it for my app. https://github.com/Saw-000/SwiftUI-DetectGestureUtil I want to use a function like this library with "import SwiftUI". The function is needed in the core maybe, isn't it?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
128
Activity
Nov ’25
Why does SwiftUI Text(date, style: .relative) show the same duration for different dates?
I’m using SwiftUI’s Text(_:style:) with the .relative style to show how long ago a date occurred. According to the docs: A style displaying a date as relative to now. I expected it to show the precise difference between a past date and the current date. However, I noticed that two dates that are 3 days apart both display the same relative string under certain conditions. Code snippet to reproduce- (using GMT time zone and the system calendar) IMPORTANT: To reproduce this, set your Mac’s system clock to 8 September 2025, 3:00 AM. SwiftUI’s relative style uses the current system time as its reference point, so changing the clock is necessary to see the behavior. Settings Mac is set to Central European Time zone (but this behaviour was also reproduced by one of my app's users in the US.) Mac OS Sequoia 15.5 XCode 16.4 tested on an iOS Simulator and a real iPhone both running iOS 18.5 struct TestDateView: View { var body: some View { // 8. July 10AM to 8. September 3AM = Shows 2 months 2 days let startDate1: Date = Calendar.current.date(from: .init(calendar: .current, timeZone: .gmt, year: 2025, month: 7, day: 8, hour: 10, minute: 0, second: 0))! // 5. July 10AM to 8. September 3AM = Shows 2 months 2 days let startDate2: Date = Calendar.current.date(from: .init(calendar: .current, timeZone: .gmt, year: 2025, month: 7, day: 5, hour: 10, minute: 0, second: 0))! // IMPORTANT!: Need to set MAC's clock to 8. September 3:00 AM to reproduce this bug VStack { Text(startDate1, style: .relative) Text(startDate2, style: .relative) } } } How exactly does the .relative style work internally? Is it expected that different dates can collapse into the same result like this, or is there a better way to use .relative to get more precise results? PS: I know about DateComponents and DateFormatter for exact calculations, but I’d like to understand this approach since it auto-updates natively with no timers or publishers.
Replies
0
Boosts
0
Views
107
Activity
Sep ’25
SwiftUI DocumentGroup blocks "Create Document" button when opening a document in conflict state
In a SwiftUI DocumentGroup, the "Create Document" button remains permanently disabled when attempting to open a document that is in a conflict state (e.g., due to simultaneous edits across devices). As a result, the user cannot create new documents, and the app becomes stuck. On macOS, the expected conflict resolution dialog appears, and the app continues to function normally. On iOS, however, the "Create Document" button stays disabled indefinitely. This behavior occurs consistently in a default SwiftUI document-based app. Steps to Reproduce: Create a new SwiftUI document-based project in Xcode; Setup iCloud Storage in Signing & Capabilities; Create an empty document and place it in a conflict state (e.g., save it simultaneously from two devices); Attempt to open the conflicted document on an iPhone or iPad; Expected Result: The user should be able to resolve the conflict and continue working; The "Create Document" button should remain functional; Actual Result: The "Create Document" button is disabled permanently; The app cannot create new documents until restarted; Environment; iOS 18, iOS 26 (latest tested); Xcode Version 16.4 (16F6) Reproduced on iPhone and iPad; Works as expected on macOS; This appears to be a blocking issue in SwiftUI’s DocumentGroup on iOS. FB20203775
Replies
0
Boosts
0
Views
139
Activity
Sep ’25
iOS 26 List selection radius
Is there any way to influence the corner radius of a selection in the list? Looking at the native Apple Mail app in the iOS 26, it should be.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
1
Views
164
Activity
Jun ’25
Alert Closures Not Firing + Navigation Animations Broken
Hi, I hope you are doing well. We have been running up against an issue in our application which despite our best efforts we cannot seem to solve. After a certain point of use (of which we cannot seem to isolate a trigger), something internally with the way SwiftUI handles animation transactions seems to be breaking. This results in the following behavior that we (and our users) are noticing: Alerts/Sheets/NavigationPath changes lose all animations Closures associated with buttons no longer fire at all. The alert disappears, but with no animation and any action associated with the button selected does nothing. This results in an infinite loop of triggering an alert, clicking on an alert action, and the alert dismissing without the corresponding action ever occurring. We have tried moving the navigationPath out of a view model (Observable) and into a @State variable on the view in case it was an issue with view pre-rendering due to path changes, but this did not improve our case. We hoisted the state and the alert presentation out of all subviews and onto the root view of our navigation destination (as this happens on a sub-page of the application) as well, and while did this seem to minimize occurrences it did not fully resolve it. The app structure of our watch app is as follows: We have a NavigationStack at the root level which wraps a TabView, containing 3 pages. Selecting a button triggers a navigation destination, presenting a detail view. The detail view is a ZStack which switches on a property contained in an @State Observable view model scoped to the detail view. The ZStack can contain one of 5 subviews, derived from a viewState enum with associated values (all of which are equatable, and by extension viewState is also an equatable type as well). One of the subviews receives a binding, which on button trigger updates the binding and thus the view containing the ZStack presents the alert. Sometimes, when this happens, the animations break, and then are subsequently broken for the remainder of the lifetime of the app until it is force-closed (not backgrounded, but a full force-close). NavigationStack { TabView { Tab1 Tab2 // triggers navigationDestination Tab3 } .navigationDestination(for:) { DestinationView() // the view containing the ZStack + Alert } } STEPS TO REPRODUCE Unfortunately we have not been able to ascertain exactly what is causing this issue as we cannot reproduce it in a sandbox environment, only when moving through the view flow associated with our code. Any debugging ideas or recommendations would be greatly appreciated, as we have already tried _printChanges and do not notice any erroneous view redraws.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
84
Activity
Sep ’25
SwiftUI List optional refreshable
Currently refreshable modifier does not support nil as a value and there's no way of disabling refreshable without recreating the whole view. There are a few posts showing how refreshable could be optionally disabled on scrollViews using: \EnvironmentValues.refresh as? WritableKeyPath<EnvironmentValues, RefreshAction?> https://stackoverflow.com/a/77587703 However, this approach doesn't seem to work with Lists. Has anyone find any solutions for this?
Replies
0
Boosts
0
Views
172
Activity
Sep ’25
Modelactors, Repository and bootloader
In iOS 26, should we have bootloader that runs the repo on startup - or should we have that inside tasks in root view? we have repos that runs as a «closed» functions, we dont throw but updates swiftdata and we use @query in the views. So what is best? and for the repo we should have a repo that runs the upserts manage relations eg? Should that run on a modelactor?
Replies
0
Boosts
0
Views
221
Activity
Sep ’25
Internal Testing App Not Showing
Hi! I am having issues with my internal testing app now showing up the same through different users devices?
Replies
0
Boosts
0
Views
75
Activity
Mar ’25
.preferredColorScheme doesn't work with .scrollEdgeEffectStyle(.hard, for: .top)
.preferredColorScheme(.dark) doesn't seem to affect app toolbar, when .scrollEdgeEffectStyle(.hard, for: .top) is used. In the attachment, you can see the title and toolbar items don't change according to current value of .preferredColorScheme (you may need to scroll a bit to achieve it) iOS 26 RC Feedback ID - FB19769073 import SwiftUI struct ContentView: View { var body: some View { NavigationStack { ScrollView(.vertical) { ForEach(0..<100) { index in Text("\(index)") .padding() .border(.blue) .background(.blue) .frame(maxWidth: .infinity) } } .scrollEdgeEffectStyle(.hard, for: .top) .navigationTitle("Test Title") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: { }) { Text("Test") } } } } .preferredColorScheme(.dark) } } #Preview { ContentView() }
Replies
0
Boosts
0
Views
106
Activity
Sep ’25