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

Created

Picker style .menu doesn't handle nil
Here's the code... import SwiftUI enum Side: String { case left case right } struct SideView: View { @State private var name: String = "" @State private var side: Side? = nil var body: some View { NavigationStack { Form { Section { TextField("Name", text: $name) Picker("Side", selection: $side) { Text("Left").tag(Side.left as Side?) Text("Right").tag(Side.right as Side?) } .pickerStyle(.menu) // displays with "Left" selected even though side is nil // .pickerStyle(.inline) // all the other styles work as expected, nothing initially selected // .pickerStyle(.palette) // .pickerStyle(.navigationLink) } } } } } #Preview("SideView") { SideView() } Even though side is nil the .menu style displays with "Left" selected. Try any of the other styles. They all display with nothing initially selected. As they should when side is nil. This seems like a bug and I've submitted feedback. ID: FB21685273 Whether it's a bug or not has anyone worked around this?
Topic: UI Frameworks SubTopic: SwiftUI
1
0
113
1w
SwiftUI/WKWebView app migrated from React Native to SwiftUI shows blank/blue screen for some users after App Store update
I’m hoping to get some insight from Apple engineers or developers who have seen similar behavior. Background We previously had a React Native / Expo iOS app in production for several years. Recently, we rebuilt the app completely from scratch as a native SwiftUI app using WKWebView (no shared code, no RN runtime). The new app architecture is: Native SwiftUI container WKWebView loading a remote web app Firebase Analytics & Crashlytics Push notifications (APNs + FCM) No local database, no persistent native state Migration scenario Users update the app via the App Store: Old app: React Native / Expo New app: native SwiftUI + WKWebView For most users, the migration works fine. However, for a about 10% of users, the following happens: The issue After updating from the old React Native app to the new SwiftUI app: The app opens The native landing screen appears (solid black OR blue background, depending on which most recent version if being installed) The app never transitions to the WKWebView No crash Force-quitting does not help Deleting the app completely and reinstalling does fix it 9/10 times, but NOT ALWAYS. From the user’s perspective: “The app is stuck on a black OR blue screen forever.” Important detail Most of the times, a full uninstall + reinstall FIXES the issue, but funny enough, NOT always.. In some cases, the issue persists: What we’ve already tried Over the last weeks, multiple iOS developers have investigated this. We have implemented and/or tested: Full rebuild in SwiftUI (no RN remnants) Aggressive cleanup on first launch after update: -- UserDefaults cleanup -- WKWebsiteDataStore cleanup -- URLCache / cookies cleanup Timeouts and fallbacks so the UI never blocks indefinitely Explicit logging of: -- app_open -- session_start -- webview_init -- webview_load_start / finish -- blank screen detection Handling: -- WKWebView content process terminated -- network / TLS / DNS errors Added a native SwiftUI landing screen (in the latest version) so users no longer see a black screen, but now they see a BLUE screen when the transition fails Observations from Analytics & Crashlytics No native crashes Very high user engagement (~99%) Very low blank-screen detection (~1–2%) The issue does not appear to be mass-scale But support still receives complaints daily from affected users This suggests a device / iOS / network-specific edge case, not a general migration failure. Hypotheses (not confirmed) We suspect one of the following, but haven’t been able to prove it: WKWebView failing to initialize under specific conditions after App Store updates TLS / ATS / CDN edge behavior affecting first WKWebView load iOS lifecycle timing issue when transitioning from SwiftUI landing view to WKWebView OS-specific WebKit state that survives reinstall (keychain? system WebKit state?) ISP / DNS / IPv6-related issues on first launch What we’re looking for We would really appreciate insight on: Are there known cases where WKWebView fails silently after an App Store update, even after reinstall? Is there any system-level WebKit state that survives app deletion? Are there best practices for transitioning from a SwiftUI landing view to WKWebView to avoid dead-ends? Any known iOS versions / device classes where this behavior is more common? Any debugging techniques beyond Crashlytics / Analytics that could surface what WebKit is failing on? We’re not looking for generic “clear cache” advice — we’ve already gone far down that path. We’re trying to understand whether this is a known WebKit edge case or something we are fundamentally missing. Thanks in advance for any pointers or shared experiences.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
60
1w
How to make a binary XCFramework self-contained with embedded resource bundles
I’m building an iOS SDK that is distributed as a binary XCFramework and consumed via Swift Package Manager using a binaryTarget. What I’ve done so far: Built the SDK using xcodebuild archive for device and simulator Created the XCFramework using xcodebuild -create-xcframework The SDK contains a resource bundle with JSON/config files The XCFramework is wrapped using SPM (code-only wrapper target) Currently, the resource bundle exists outside the XCFramework, and the host app needs to add it manually during integration. I want to avoid this and make the SDK completely self-contained. What I’m trying to achieve: Embed the resource bundle inside the SDK framework so that each XCFramework slice contains it Ensure the SDK can load its assets internally at runtime without any host app changes Questions: What is the correct way to embed a .bundle inside a framework so it gets packaged into each XCFramework slice during archiving? Which Xcode build phases or build settings are required for this (e.g., Copy Bundle Resources, SKIP_INSTALL, etc.)? At runtime, what is the recommended approach for locating and loading this embedded bundle from within the SDK code? Any guidance or best practices for achieving this would be helpful.
0
0
58
1w
Apple App Site Association (AASA) and Universal Links Issue
Hi Everyone We are seeking inputs regarding an issue we are observing with Apple App Site Association (AASA) and Universal Links in our iOS application. In our iOS Mobile App, we have a LogIn button which when clicked , opens a webv view to open a login page using WebView. The login flow follows the OAuth mechanism to get the token after successful login. But despite having a correctly configured AASA file and associated domains setup, our application does not consistently handle Universal Links and we simply end up getting a blank page.So, after successful login the control never gets passed back the iOS Mobile app and flow gets stuck on the browser only that just displays a blank page. Earlier the same OAuth flow was working fine when we were using the 'com.test.app://oauth2redirect' comnvention. Based on our investigation, we suspect this behavior may be related to the use of in-app browsers or embedded webviews, rather than an issue with our app or server-side configuration. From our research and observations, it appears that this may be a known iOS behavior and platform limitation, where Universal Links do not automatically work within third-party in-app browsers or webviews (for example, those embedded in apps such as social media or other container applications). Looks like the Universal Links are primarily designed to work when links are opened from system-level contexts such as Safari, Mail, Messages, or Notes, under specific conditions. Given this, we wanted to confirm with you: If you have developed a mobile app earlier that uses the (AASA) and Universal Links in iOS application. Join us with a quick call and we can walkthrough what we have done and see if there is anything missing. Thanks Rahul
Topic: UI Frameworks SubTopic: General
1
0
141
1w
How to trigger ShieldConfigurationExtension?
On pressing the secondary button on my ShieldConfigurationExtension, I remove the shields by setting shields in the named ManagedStore to nil in my ShieldActionExtension. // ShieldActionExtension.swift let store = ManagedSettingsStore() store.shield.applications = nil store.shield.applicationCategories = nil Now after some duration I want to re-apply the shields again for which I do the following: // ShieldActionExtension.swift DispatchQueue.main.asyncAfter(deadline: .now() + unlockDuration) { [weak self] in self?.reapplyShields(for: sessionId, application: application) } private func reapplyShields(for sessionId: String, application: ApplicationToken) { store.shield.applications = Set([application]) } Followed by the completionHandler: // ShieldActionExtension.swift completionHandler(.defer) Now the expectation is ShieldConfigurationExtension should be re-triggered with store.shield.applications = Set([application]), however I see the default iOS screen time shield. This behavior is experience when the blocked app is running in the foreground. However, if I close and re-open the blocked app - the ShieldConfigurationExtension is trigerred again correctly. If I do a completionHandler(.none) instead, the overriden configuration method in ShieldConfigurationExtension is not triggered. How do I make sure ShieldConfigurationExtension is triggered if the blocked app is running in the foreground when the shields are re-applied again?
0
0
104
1w
How can I be notified if another app goes full screen on macOS?
Is there any way I can know that another app has gone full screen? Please note that this is not what NSWindowDidEnterFullScreenNotification does, that only works for my own windows. As for why I need to know: Say you're playing a YouTube video full screen. The video fills up the main display, and if there's a second display, it goes black. Well, mostly. I have a utility app with small status windows that remain on top. I'd like to be polite and hide them in this scenario.
1
1
210
2w
SwiftUI .task does not update its references on view update
I have this sample code import SwiftUI struct ContentView: View { var body: some View { ParentView() } } struct ParentView: View { @State var id = 0 var body: some View { VStack { Button { id+=1 } label: { Text("update id by 1") } TestView(id: id) } } } struct TestView: View { var sequence = DoubleGenerator() let id: Int var body: some View { VStack { Button { sequence.next() } label: { Text("print next number").background(content: { Color.green }) } Text("current id is \(id)") }.task { for await number in sequence.stream { print("next number is \(number)") } } } } final class DoubleGenerator { private var current = 1 private let continuation: AsyncStream<Int>.Continuation let stream: AsyncStream<Int> init() { var cont: AsyncStream<Int>.Continuation! self.stream = AsyncStream { cont = $0 } self.continuation = cont } func next() { guard current >= 0 else { continuation.finish() return } continuation.yield(current) current &*= 2 } } the print statement is only ever executed if I don't click on the update id by 1 button. If i click on that button, and then hit the print next number button, the print statement doesn't print in the xcode console. I'm thinking it is because the change in id triggered the view's init function to be called, resetting the sequence property and so subsequent clicks to the print next number button is triggering the new version of sequence but the task is still referring its previous version. Is this expected behaviour? Why in onChange and Button, the reference to the properties is always up to date but in .task it is not?
1
0
167
2w
Performance Issues with ActionButton in MarketplaceKit – XPC Calls Causing UI Hangs
Hi all, I’m working on the alternative marketplace app and using MarketplaceKit and ActionButton. On the main page, users see a list of items, each with an ActionButton. I’m experiencing significant UI hangs when this page loads. What I’ve Observed: Instruments (Hangs and SwiftUI profilers) show that the hangs occur when ActionButton instances are rendered. Creating or updating ActionButton properties triggers synchronous XPC communication with the managedappdistributiond process on the main thread. Each XPC call takes about 2-3 ms, but with many ActionButtons, the cumulative delay is noticeable and impacts the user experience. I have tested on iOS 18.7 and 26.1, using Xcode 26.2. But in general, the issue is not specific to a device or iOS version. The problem occurs in both Debug and Release builds. Hangs can be severe depending on the number of items in a section, generally between 200-600 ms, resulting in noticeable lag and a poor user experience. I haven’t found much documentation on the internal workings of ActionButton or why these XPC calls are necessary. I have tried Lazy loading and reducing the amount of ActionButton instances. That makes the hangs less noticeable, but there are still hitches when new sections with items are added to the view hierarchy. This is not an issue with SwiftUI or view updates in general. If I replace ActionButton with UIButton, the hangs are completely gone. Minimal Example: Here’s a simplified version of how I’m using ActionButton in my SwiftUI view. The performance issue occurs when many of these views are rendered in the list: struct ActionButtonView: UIViewRepresentable { let viewModel: ActionButtonViewModel let style: ActionButtonStyle func makeUIView(context: Context) -> ActionButton { return ActionButton(action: viewModel.action) } func updateUIView(_ uiView: ActionButton, context: Context) { uiView.update(\.size, with: context.coordinator.size) uiView.update(\.label, with: viewModel.title) uiView.update(\.isEnabled, with: context.environment.isEnabled) uiView.update(\.fontSize, with: style.scaledFont(for: viewModel.title)) uiView.update(\.backgroundColor, with: style.backgroundColor.color) uiView.update(\.tintColor, with: style.textAndIconColor) uiView.update(\.cornerRadius, with: style.cornerRadius(height: uiView.frame.size.height)) uiView.update(\.accessibilityLabel, with: viewModel.accessibilityLabel) uiView.update(\.accessibilityTraits, with: .button) uiView.update(\.accessibilityUserInputLabels, with: viewModel.accesibilityUserInputLabels) uiView.update(\.tintAdjustmentMode, with: .normal) } func makeCoordinator() -> Coordinator { Coordinator(viewModel: viewModel) } class Coordinator: NSObject { ... } } extension ActionButton { fileprivate func update<T>(_ keyPath: WritableKeyPath<ActionButton, T>, with value: T) where T: Equatable { if self[keyPath: keyPath] == value { return } var mutableSelf = self mutableSelf[keyPath: keyPath] = value } } From the Instruments samples, it’s clear that the performance issues originate from NativeActionButtonView.makeUIView(context:) and NativeActionButtonView.updateUIView(_:context:). The following stack trace is common for all blocking calls, indicating that NSXPCConnection is being used for cross-process communication: mach_msg2_trap mach_msg2_internal mach_msg_overwrite mach_msg _dispatch_mach_send_and_wait_for_reply dispatch_mach_send_with_result_and_wait_for_reply xpc_connection_send_message_with_reply_sync __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] ___forwarding___ _CF_forwarding_prep_0 __35-[_UISlotView _setContentDelegate:]_block_invoke_2 -[_UISlotView _updateContent] ... NativeActionButtonView.sizeThatFits(_:uiView:context:) protocol witness for UIViewRepresentable.sizeThatFits(_:uiView:context:) in conformance NativeActionButtonView ... Additionally, the Thread State Trace shows that during the XPC calls, the main thread is blocked and is later made runnable by managedappdistributiond. This confirms that the app is indeed communicating with the managedappdistributiond process. Since there is limited documentation and information available, I have some questions: Is there a way to batch update ActionButton properties to reduce the number of XPC calls? Is it possible to avoid or defer XPC communication when creating/updating ActionButton instances? Are there best practices for efficiently rendering large numbers of ActionButtons in SwiftUI? Is this a known issue, and are there any recommended workarounds? Can Apple provide more details on ActionButton’s internal behavior and XPC usage? Any insights or suggestions would be greatly appreciated!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
52
2w
Accessory View Not Displayed When Switching Input Methods via Bluetooth Keyboard
Hello everyone, When I press Control + Space on my Bluetooth keyboard to trigger input method switching, the accessory view fails to appear. This prevents me from quickly identifying the current input method type. Upon inspecting the View Hierarchy, I noticed that UICursorAccessoryView is not being created. For context, my input method responder inherits from UIResponder and conforms to the UITextInputTraits, UIKeyInput, and UITextInput protocols. The accessory view displays normally during accented input and Chinese input. Could you please guide me on how to troubleshoot this issue?
4
0
380
2w
SwiftUI menu not resizing images
I failed to resize the icon image from instances of NSRunningApplication. I can only get 32×32 while I'm expecting 16×16. I felt it unintuitive in first minutes… Then I figured out that macOS menu seems not allowing many UI customizations (for stability?), especially in SwiftUI. What would be my best solution in SwiftUI? Must I write some boilerplate SwiftUI-AppKit bridging?
1
0
78
2w
does ios26 really prevent toolbars and child views from functioning?
I'm building an app with a min iOS of 26. In iOS 26, bottom toolbars are attached to the NavStack where in ios18 they were attached to a vstack or scrollview. But in ios26 if the toolbar is attached to something like a vstack, it displays too low on an iPhone 16e and sits behind the tab bar. Fine. But with a parent-child view, the parent has a NavStack (with bottom toolbar attached) and the child view doesn't have a NavStack. So...that's a problem. The functional impact of this contradiction (bottom toolbars go on the NavStack and child views don't have a NavStack) is actually two problems. the parent view bottom toolbar shows up on the child view (because it's the closest NavStack) whether it's appropriate on the view or not. the child view can't have a viable bottom toolbar because without a NavStack any buttons are hidden behind the tab view. The second problem can be worked around using a top toolbar or safe area edge inset instead of a toolbar at the bottom or something. But those don't solve the first problem of the parent view bleeding through. So, I have to be crazy, right. Apple wouldn't create a scenario where bottom toolbars are not functional on parent-child views in ios26. Any suggestions that I'm missing?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
56
2w
WWDC21 Demystify SwiftUI question
When the guy was talking about structural identity, starting at about 8:53, he mentioned how the swiftui needs to guarantee that the two views can't swap places, and it does this by looking at the views type structure. It guarantees that the true view will always be an A, and the false view will always be a B. Not sure exactly what he means because views can't "swap places" like dogs. Why isn't just knowing that some View is shown in true, and another is shown in false, enough for its identity? e.g. The identity could be "The view on true" vs "The view on false", same as his example with "The dog on the left" vs "The dog on the right"
0
0
58
2w
How to animate `UIHostingController.view` frame when my View's size changes?
I have a UIHostingController on which I have set: hostingController.sizingOptions = [.intrinsicContentSize] The size of my SwiftUI content changes with animation (I update a @Published property on an ObservableObject inside a withAnimation block). However, I notice that my hostingController.view just jumps to the new frame without animating the change. Question: how can I animate the frame changes in UIHostingController that are caused by sizingOptions = [.intrinsicContentSize]
3
1
183
2w
UIKit: readableContentGuide is too wide on iPads iOS 26.x
We noticed in multiple apps that readableContentGuide is way too wide on iOS 26.x. Here are changes between iPad 13inch iOS 18.3 and the same device iOS 26.2 (but this affects also iOS 26.0 and iOS 26.1): 13 inch iOS 18 Landscape ContentSizeCategory: XS, Width: 1376.0 , Readable Width: 560.0 S, Width: 1376.0 , Readable Width: 600.0 M, Width: 1376.0 , Readable Width: 632.0 L, Width: 1376.0 , Readable Width: 664.0 XL, Width: 1376.0 , Readable Width: 744.0 XXL, Width: 1376.0 , Readable Width: 816.0 XXXL,Width: 1376.0 , Readable Width: 896.0 A_M, Width: 1376.0 , Readable Width: 1096.0 A_L, Width: 1376.0 , Readable Width: 1280.0 A_XL,Width: 1376.0 , Readable Width: 1336.0 13 inch iOS 26 Landscape ContentSizeCategory: XS, Width: 1376.0 , Readable Width: 752.0 S, Width: 1376.0 , Readable Width: 800.0 M, Width: 1376.0 , Readable Width: 848.0 L, Width: 1376.0 , Readable Width: 896.0 XL, Width: 1376.0 , Readable Width: 1000.0 XXL, Width: 1376.0 , Readable Width: 1096.0 XXXL,Width: 1376.0 , Readable Width: 1200.0 A_M, Width: 1376.0 , Readable Width: 1336.0 The code I used: class ViewController: UIViewController { lazy var readableView: UIView = { let view = UIView() view.backgroundColor = .systemBlue view.translatesAutoresizingMaskIntoConstraints = false return view }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(readableView) NSLayoutConstraint.activate([ readableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), readableView.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor), readableView.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor), readableView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor) ]) } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if readableView.frame.width > 0 { let orientation = UIDevice.current.orientation print(""" ContentSizeCategory: \(preferredContentSizeCategoryAsString()) Width: \(view.frame.width) , Readable Width: \(readableView.frame.width), Ratio: \(String(format: "%.1f", (readableView.frame.width / view.frame.width) * 100))% """) } } func preferredContentSizeCategoryAsString() -> String { switch UIApplication.shared.preferredContentSizeCategory { case UIContentSizeCategory.accessibilityExtraExtraExtraLarge: return "A_XXXL" case UIContentSizeCategory.accessibilityExtraExtraLarge: return "A_XXL" case UIContentSizeCategory.accessibilityExtraLarge: return "A_XL" case UIContentSizeCategory.accessibilityLarge: return "A_L" case UIContentSizeCategory.accessibilityMedium: return "A_M" case UIContentSizeCategory.extraExtraExtraLarge: return "XXXL" case UIContentSizeCategory.extraExtraLarge: return "XXL" case UIContentSizeCategory.extraLarge: return "XL" case UIContentSizeCategory.large: return "L" case UIContentSizeCategory.medium: return "M" case UIContentSizeCategory.small: return "S" case UIContentSizeCategory.extraSmall: return "XS" case UIContentSizeCategory.unspecified: return "U" default: return "D" } } } Please advise, it feels completely broken. Thank you.
1
1
119
2w
Text with .secondary vanishes when Material background is clipped to UnevenRoundedRectangle in ScrollView
I just found a weird bug: If you place a Text view using .foregroundStyle(.secondary), .tertiary, or other semantic colors inside a ScrollView, and apply a Material background clipped to an UnevenRoundedRectangle, the text becomes invisible. This issue does not occur when: The text uses .primary or explicit colors (e.g., .red, Color.blue), or The background is clipped to a standard shape (e.g., RoundedRectangle). A minimal reproducible example is shown below: ScrollView{ VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello World.") .font(.system(size: 15)) .foregroundStyle(.quinary) } } .padding() .frame(height: 100) .background(Material.regular) .clipShape(UnevenRoundedRectangle(topLeadingRadius: 10,bottomLeadingRadius: 8,bottomTrailingRadius:8, topTrailingRadius: 8))
0
0
129
2w
SwiftUI TextEditor: replaced text jumps outside current selection
I have a text editor where I replace the selected text when a button is tapped. Most of the time it works, but sometimes the new text is inserted at the end of the text instead of at the selected position. Is this a bug? @Bindable var note: Richnote @State private var selection = AttributedTextSelection() var body: some View { VStack { TextEditor(text: $note.content, selection: $selection) Button("Replace text") { let textToInsert = "A long text that makes me think lalala" note.content.replaceSelection(&selection, withCharacters: textToInsert) }
Topic: UI Frameworks SubTopic: SwiftUI
2
0
65
2w
Why MapKit Is So Unpredictable for macOS?
I have an existing iOS app with MapKit. It always shows the current user location with UserAnnotation. But the same isn't true for macOS. I have this sample macOS application in SwiftUI. In the following, the current user location with a large blue dot appears only occasionally. It won't, 19 of 20 times. Why is that? I do have a location privacy key in Info.plist. And the Location checkbox is on under Signing & Capabilities. import SwiftUI import MapKit struct ContentView: View { @State private var markerItems: [MarkerItem] = [ MarkerItem(name: "Farmers Market 1", lat: 35.681, lon: 139.691), MarkerItem(name: "Farmers Market 2", lat: 35.685, lon: 139.695), MarkerItem(name: "Farmers Market 3", lat: 35.689, lon: 139.699) ] @State private var position: MapCameraPosition = .automatic var body: some View { Map(position: $position) { UserAnnotation() ForEach(markerItems, id: \.self) { item in Marker(item.name, coordinate: CLLocationCoordinate2D(latitude: item.lat, longitude: item.lon)) } } .mapControlVisibility(.hidden) .mapStyle(.standard(elevation: .realistic)) .ignoresSafeArea() } } #Preview { ContentView() } struct MarkerItem: Hashable { let name: String let lat: Double let lon: Double }
0
0
32
2w