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

How to Use AccessorySetupKit to Automatically Trigger Hardware Pairing Screen in the Background?
Hello everyone, I’m currently developing an iOS app and would like to leverage the AccessorySetupKit framework introduced in iOS 18 to implement pairing functionality with our company's custom hardware product. The specific requirements are as follows: Our hardware supports both Bluetooth and Wi-Fi connections, and both are enabled. When the hardware device is in proximity to an iPhone, I want the device to be automatically recognized, and a pairing screen similar to the one in AccessorySetupKit should appear. Users should be able to perform the pairing process without needing to open our app, even if the app is not in the foreground. The system-level pairing screen should show the hardware information and allow the user to proceed with the pairing. My questions are: Does AccessorySetupKit allow the pairing screen to trigger when the app is running in the background, or must the app be in the foreground? How should I configure AccessorySetupKit to automatically recognize and display my company’s hardware device information? Are there any specific configurations or code implementations needed? Do I need to implement any specific Bluetooth/Wi-Fi advertising broadcasts to ensure the device is correctly detected by the iOS system when in proximity? Are there any additional permissions or configurations required, especially for handling background tasks? Thank you very much for your help, and I look forward to your advice and insights!
Topic: UI Frameworks SubTopic: UIKit
0
0
78
May ’25
SwiftUI Gestures prevent subview gesture when build with XCode 16 in iOS 18
I have a view with some buttons, and add 2 gestures using simultaneously. My app works well when built with XCode less than 16, or run on iOS less than 18.0. Example code is below: VStack(spacing: 0) { Button { print("button tapped") } label: { Rectangle() .foregroundColor(.red) } .frame(height: 100) } .gesture( DragGesture(minimumDistance: 0) .onEnded { value in print("single tap") } .simultaneously(with: TapGesture(count: 2).onEnded { print("double tap") } ) ) .frame(width: 200, height: 200) .border(Color.purple) I expect the action on Button should be recognized and print out button tapped, but only single tap and double tap are recognized
0
1
359
Mar ’25
ApplePay QR code popup language
Hi Team, when launching an ApplePay session from a 3rd party browser where we get the QR code popup - is it possible to affect the popup's language? We are setting the button's language via locale parameter, but when the QR code pop's up it does not respect this setting (seems like it respects browser language). Button in Arabic Corresponding popup Browser language Arabic Coresponding popup I was unable to find anything in the documentation - could you please either point me to the relevant documentation or confirm/deny that it is possible to request a language for the popup via tjr javascript API? Kind regards Tomas
0
0
106
May ’25
How to correctly and simply remove the edges of listStyle sidebar?
Hello, I've managed to get rid of these spaces in different ways. Using scrollview, giving negative insets, rewriting modifiers from scratch with plain style etc. But I couldn't solve this with a simple solution. I've read comments from many people experiencing similar problems online. It seems like there isn't a simple modifier to remove these spaces when we use sidebar as the list style in SwiftUI, or I couldn't find the simple solution. I wonder what's the simplest and correct way to reset these spaces? let numbers = Array(1...5) @State private var selected: Int? var body: some View { List(numbers, id: \.self, selection: $selected) { number in HStack { Text("Test") Spacer() } .frame(maxWidth: .infinity, alignment: .leading) } .listStyle(.sidebar) } }
0
0
190
Mar ’25
Can SwiftUI TextFields in a List on macOS be marked as always editable?
In SwiftUI's List, on macOS, if I embed a TextField then the text field is presented as non-editable. If the user clicks on the text and waits a short period of time, the text field will become editable. I'm aware this is generally the correct behaviour for macOS. However, is there a way in SwiftUI to supress this behaviour such that the TextField is always presented as being editable? I want a scrollable, List of editable text fields, much like how a Form is presented. The reason I'm not using a Form is because I want List's support for reordering by drag-and-drop (.onMove). Use Case A view that allows a user to compose a questionnaire. They are able to add and remove questions (rows) and each question is editable. They require drag-and-drop support so that they can reorder the questions.
0
0
133
May ’25
NSHostingController menu not activated
I'm attempting to write a macOS version of https://stackoverflow.com/a/74935849/2178159. From my understanding, I should be able to set the menu property of an NSResponder and it will automatically show on right click. I've tried a couple things: A: set menu on an NSHostingController's view - when I do this and right or ctrl click, nothing happens. B: set menu on NSHostingController directly - when I do this I get a crash Abstract method -[NSResponder setMenu:] called from class _TtGC7SwiftUI19NSHostingControllerGVS_21_ViewModifier_...__. Subclasses must override C: manually call NSMenu.popup in a custom subclasses of NSHostingController or NSView's rightMouseDown method - nothing happens. extension View { func contextMenu(menu: NSMenu) -> some View { modifier(ContextMenuViewModifier(menu: menu)) } } struct ContextMenuViewModifier: ViewModifier { let menu: NSMenu func body(content: Content) -> some View { Interaction_UI( view: { content }, menu: menu ) .fixedSize() } } private struct Interaction_UI<Content: View>: NSViewRepresentable { typealias NSViewType = NSView @ViewBuilder var view: Content let menu: NSMenu func makeNSView(context: Context) -> NSView { let v = NSHostingController(rootView: view) // option A - no effect v.view.menu = menu // option B - crash v.menu = menu return v.view } func updateNSView(_ nsView: NSViewType, context: Context) { // part of option A nsView.menu = menu } }
0
0
271
Mar ’25
iOS 18.4.1 Keyboard Extension Dark Mode Background Issue
Background Color Issue in Custom Keyboard Extension in Dark Mode for iOS 18.4.1 Issue Description I'm developing a custom keyboard extension for iOS 18.4.1 and experiencing an issue with background colors when using Dark Mode. After a user makes a selection from a menu in the keyboard, the background color of a view unexpectedly changes to white instead of maintaining the dark theme color. Steps to Reproduce Enable Dark Mode on the device Activate the custom keyboard in any text field Perform a specific interaction (selecting an item from a menu) After selection, the background of the view turns white instead of remaining dark Technical Details The issue appears to be related to UIScrollView's background color behavior The problem doesn't occur on initial display of the menu, only after user interaction I've attempted to set background colors explicitly on the view hierarchy, but the issue persists Environment iOS 18.4.1 Xcode 16.0 Custom keyboard extension Questions Has anyone encountered similar issues with view background colors changing after user interactions in keyboard extensions on iOS 18.4.1? Is there a recommended approach to maintain dark background colors in keyboard extensions after user selections? Could this be related to a change in how UIScrollView handles background colors in recent iOS versions? Thank you for any assistance or insights.
Topic: UI Frameworks SubTopic: UIKit
0
0
94
May ’25
Multipeer Connectivity with iOS devices
I used the Multipeer Connectivity Framework to allow players of my game app to see the highest score along with their own score as the game progresses. It works fine running in 3 or 4 simulators in Xcode. However, I was just told by two Apple support reps that bluetooth connectivity is not allowed between two Apple devices, other than for watches, AirPods, headphones, etc. My question is: can two iPhones or iPads connect for peer-to-peer play? Can they play offline? If the answer is yes to either or both of those questions, how do I get that to happen since I get an error message when trying to connect two iPhones via bluetooth even though they can see each other in the Other Devices list? If the answer is no, then why does Apple provide a Multipeer Connectivity Framework and simulate that type of device to device connection with the Xcode simulators?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
173
Feb ’25
CarPlay selection highlightning
It looks like I'm one of the rare developers dealing with CarPlay... I develop a CarPlay extension for my apps. A few things: especially when using the CarPlay I/O window in iOS Simulator, I get random selection highlightning for list items: I have three list templates in a tab template; once I reselect a list using the tab which has been selected before, the initial list item highlights / returns to normal every refresh of the list content; while this doesn't happen for my real world Sony CarPlay device, I'd rather not see such disturbing highlighting for my users. I do not update the template structs or items here, it is just content like text of detailText I update. Question: how to remove highlightning programmatically - especially for devices with touch screen? I have one user who reports auto-selection of UI elements while driving; I assume this is some problem with his touch screen, but it may be a general issue too. Question: anyone with similar observations connecting my iPhone to the stand-alone Car Play simulator doesn't work; I had it working before, so it might be related to a recent iOS beta... Any hints / observations are welcome. The CarPlay community really seems to be small and I'd like to hear other's experience on the named items.
0
0
86
May ’25
SensorKit Data Not Retrieving
I have received permission from Apple to access SensorKit data for my app. I have granted all necessary permissions, but no data is being retrieved. The didCompleteFetch method is being called, but I’m unsure where to find event data like Device Usage and Ambient Light. Additionally, the didFetchResult method is never called. Could anyone please assist me in resolving this issue? Any guidance or troubleshooting steps would be greatly appreciated. import SensorKit class ViewController: UIViewController, SRSensorReaderDelegate { let store = SRSensorReader(sensor: .deviceUsageReport) override func viewDidLoad() { super.viewDidLoad() requestSensorAuthorization() } func requestSensorAuthorization() { var sensors: Set<SRSensor> = [ .accelerometer, .deviceUsageReport, .messagesUsageReport, .visits, .keyboardMetrics, .phoneUsageReport, .ambientLightSensor ] if #available(iOS 16.4, *) { sensors.insert(.mediaEvents) } SRSensorReader.requestAuthorization(sensors: sensors) { error in if let error = error { print("Authorization failed: \(error.localizedDescription)") } else { self.store.startRecording() self.requestSensorData() print("Authorization granted for requested sensors.") } } } func requestSensorData() { let fromTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().addingTimeInterval(-60 * 60).timeIntervalSinceReferenceDate) let toTime = SRAbsoluteTime.fromCFAbsoluteTime(_cf: Date().timeIntervalSinceReferenceDate) let request = SRFetchRequest() request.from = fromTime request.to = toTime request.device = SRDevice.current store.fetch(request) store.delegate = self } func sensorReader(_ reader: SRSensorReader, didCompleteFetch fetchRequest: SRFetchRequest) { print("Fetch request completed: \(fetchRequest.from) to \(fetchRequest.to)") Task { do { let samples = try await reader.fetch(fetchRequest) print("Samples count: \(samples)") } catch { print("Error Fetching Data: \(error.localizedDescription)") } } } func sensorReader(_ reader: SRSensorReader, fetching fetchRequest: SRFetchRequest, didFetchResult result: SRFetchResult<AnyObject>) -> Bool { print(result) return true } }
0
0
229
Mar ’25
Remove persistent bottom gray bar at the bottom when using hardware keyboard
DESCRIPTION OF PROBLEM When using SwiftUI’s TextField or TextEditor on iPadOS, a persistent gray or default system material bar appears at the bottom of the screen. This gray bar is not present in Apple’s native apps (such as Notes, Mail, Messages) or in third-party apps like ChatGPT and Beeper STEPS TO REPRODUCE Create a TextField or TextEditor. Run the code, click on it, without software keyboard enabled.
0
0
123
May ’25
must use voip + livekit to developing, When incoming offline messages arrive at the device through VoIP, call ConversationManager The method of reporting NewIncomingConversation (uuid: update:) will crash in second or more time
now i must use voip + livekit to developing, When incoming offline messages arrive at the device through VoIP, call ConversationManager The method of reporting NewIncomingConversation (uuid: update:) only first time can push new system UI,second or more time will crash, and acrsh stack appears to indicate that callkit has not been called
Topic: UI Frameworks SubTopic: General
0
0
360
Feb ’25
Food-Truck-Sample navigation broken from Live Activity?
https://github.com/apple/sample-food-truck Hi! I'm seeing what looks like some weird navigation issue in the Food Truck app. It's from the Live Activity that should deep link to a specific point in the app. There seems be some state where the app is not linking to the correct component. Here are my repro steps on iPhone: Start live activity from OrderDetailView. Navigate to Sidebar component. Tap the Live Activity. App opens TruckView. The App should be opening the OrderDetailView for the Order that was passed to the Live Activity. This seems to work when the app is not currently on Sidebar. Any ideas? I'm testing this on iPhone OS 18.4.1. Is this an issue inside NavigationSplitView? Is this an issue with how Food Truck handles deeplinking?
0
0
66
May ’25
Occasional PDFKit crash at PageLayout::getWordRange(unsigned long, long)
At this line of code (SketchTextSelectionManager.swift:449), sometimes there will be crashes based on crashlytics reports. let selection = pdfPage.selectionForWord(at: location) This is directly calling into PDFKit's PDFPage#selection method: https://developer.apple.com/documentation/pdfkit/pdfpage/selectionforword(at:) Attached the full stacktrace: Crashed: com.apple.root.user-initiated-qos.cooperative 0 CoreGraphics 0x30c968 PageLayout::getWordRange(unsigned long, long) const + 908 1 CoreGraphics 0x30bbc0 PageLayout::getTextRangeIndex(CGPoint, CGPDFSelectionType, SelectionPrecision) const + 2292 2 CoreGraphics 0x44a53c CGPDFSelectionCreateBetweenPointsWithOptions + 384 3 PDFKit 0x8d5f8 -[PDFPage selectionFromPoint:toPoint:type:] + 168 4 PDFKit 0x92040 -[PDFPage _rvItemAtPoint:] + 64 5 PDFKit 0x91f4c -[PDFPage rvItemAtPoint:] + 84 6 PDFKit 0x8caa8 -[PDFPage selectionForWordAtPoint:] + 40 7 MyApp 0x8420e0 closure #1 in SketchTextSelectionManager.startNewTextSelection(pageId:location:) + 449 (SketchTextSelectionManager.swift:449) 8 MyApp 0x841a70 SketchTextSelectionManager.startNewTextSelection(pageId:location:) + 205 (CurrentNoteManager.swift:205) 9 libswift_Concurrency.dylib 0x61104 swift::runJobInEstablishedExecutorContext(swift::Job*) + 252 10 libswift_Concurrency.dylib 0x63a28 (anonymous namespace)::ProcessOutOfLineJob::process(swift::Job*) + 480 11 libswift_Concurrency.dylib 0x611c4 swift::runJobInEstablishedExecutorContext(swift::Job*) + 444 12 libswift_Concurrency.dylib 0x62514 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 144 13 libdispatch.dylib 0x15d8c _dispatch_root_queue_drain + 392 14 libdispatch.dylib 0x16590 _dispatch_worker_thread2 + 156 15 libsystem_pthread.dylib 0x4c40 _pthread_wqthread + 228 16 libsystem_pthread.dylib 0x1488 start_wqthread + 8 ```
0
1
321
Feb ’25
cannot save event
iOS 18.4.1 When I change a Google type event to an iCloud type, a "Cannot Save Event" prompt box pops up. We have also received user feedback that recurring events also fail to save. After updating to iOS 18.4 when trying to save changes to an existing repeating event, the message "Cannot Save Event" will appear. EventKitUI
Topic: UI Frameworks SubTopic: UIKit
0
0
64
May ’25
What is the proper way to format a generic subview view when hoping to have it work with both an @State and an @Bindable?
Let's say you have a protocol that can work with both classes and structs but you want to have a uniform UI to make edits. What is the recommended way to have one view that will take both? App import SwiftUI @main struct ObservationTesterApp: App { var body: some Scene { WindowGroup { ContentView(existence: Existence()) } } } Types import Foundation protocol Dateable { var timestamp:Date { get set } } struct Arrival:Dateable { var timestamp:Date } @Observable class Existence:Dateable { var timestamp:Date init(timestamp: Date) { self.timestamp = timestamp } } extension Existence { convenience init() { self.init(timestamp: Date()) } } ContentView, etc // // ContentView.swift // ObservationTester // // import SwiftUI struct EditDateableView<TimedThing:Dateable>:View { @Binding var timed:TimedThing //note that this currently JUST a date picker //but it's possible the protocol would have more var body:some View { DatePicker("Time To Change", selection: $timed.timestamp) } } #Preview { @Previewable @State var tt = Arrival(timestamp: Date()) EditDateableView<Arrival>(timed: $tt) } struct ContentView: View { @State var arrival = Arrival(timestamp: Date()) @Bindable var existence:Existence var body: some View { //this work around also not allowed. "self is immutable" // let existBinding = Binding<Existence>(get: { existence }, set: { existence = $0 }) VStack { EditDateableView(timed: $arrival) //a Binding cant take a Bindable //EditDateableView<Existence>(timed: $existence) } .padding() } } #Preview { ContentView(existence: Existence()) }
0
0
133
May ’25