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

A Summary of the WWDC25 Group Lab - UI Frameworks
At WWDC25 we launched a new type of Lab event for the developer community - Group Labs. A Group Lab is a panel Q&A designed for a large audience of developers. Group Labs are a unique opportunity for the community to submit questions directly to a panel of Apple engineers and designers. Here are the highlights from the WWDC25 Group Lab for UI Frameworks. How would you recommend developers start adopting the new design? Start by focusing on the foundational structural elements of your application, working from the "top down" or "bottom up" based on your application's hierarchy. These structural changes, like edge-to-edge content and updated navigation and controls, often require corresponding code modifications. As a first step, recompile your application with the new SDK to see what updates are automatically applied, especially if you've been using standard controls. Then, carefully analyze where the new design elements can be applied to your UI, paying particular attention to custom controls or UI that could benefit from a refresh. Address the large structural items first then focus on smaller details is recommended. Will we need to migrate our UI code to Swift and SwiftUI to adopt the new design? No, you will not need to migrate your UI code to Swift and SwiftUI to adopt the new design. The UI frameworks fully support the new design, allowing you to migrate your app with as little effort as possible, especially if you've been using standard controls. The goal is to make it easy to adopt the new design, regardless of your current UI framework, to achieve a cohesive look across the operating system. What was the reason for choosing Liquid Glass over frosted glass, as used in visionOS? The choice of Liquid Glass was driven by the desire to bring content to life. The see-through nature of Liquid Glass enhances this effect. The appearance of Liquid Glass adapts based on its size; larger glass elements look more frosted, which aligns with the design of visionOS, where everything feels larger and benefits from the frosted look. What are best practices for apps that use customized navigation bars? The new design emphasizes behavior and transitions as much as static appearance. Consider whether you truly need a custom navigation bar, or if the system-provided controls can meet your needs. Explore new APIs for subtitles and custom views in navigation bars, designed to support common use cases. If you still require a custom solution, ensure you're respecting safe areas using APIs like SwiftUI's safeAreaInset. When working with Liquid Glass, group related buttons in shared containers to maintain design consistency. Finally, mark glass containers as interactive. For branding, instead of coloring the navigation bar directly, consider incorporating branding colors into the content area behind the Liquid Glass controls. This creates a dynamic effect where the color is visible through the glass and moves with the content as the user scrolls. I want to know why new UI Framework APIs aren’t backward compatible, specifically in SwiftUI? It leads to code with lots of if-else statements. Existing APIs have been updated to work with the new design where possible, ensuring that apps using those APIs will adopt the new design and function on both older and newer operating systems. However, new APIs often depend on deep integration across the framework and graphics stack, making backward compatibility impractical. When using these new APIs, it's important to consider how they fit within the context of the latest OS. The use of if-else statements allows you to maintain compatibility with older systems while taking full advantage of the new APIs and design features on newer systems. If you are using new APIs, it likely means you are implementing something very specific to the new design language. Using conditional code allows you to intentionally create different code paths for the new design versus older operating systems. Prefer to use if #available where appropriate to intentionally adopt new design elements. Are there any Liquid Glass materials in iOS or macOS that are only available as part of dedicated components? Or are all those materials available through new UIKit and AppKit views? Yes, some variations of the Liquid Glass material are exclusively available through dedicated components like sliders, segmented controls, and tab bars. However, the "regular" and "clear" glass materials should satisfy most application requirements. If you encounter situations where these options are insufficient, please file feedback. If I were to create an app today, how should I design it to make it future proof using Liquid Glass? The best approach to future-proof your app is to utilize standard system controls and design your UI to align with the standard system look and feel. Using the framework-provided declarative API generally leads to easier adoption of future design changes, as you're expressing intent rather than specifying pixel-perfect visuals. Pay close attention to the design sessions offered this year, which cover the design motivation behind the Liquid Glass material and best practices for its use. Is it possible to implement your own sidebar on macOS without NSSplitViewController, but still provide the Liquid Glass appearance? While technically possible to create a custom sidebar that approximates the Liquid Glass appearance without using NSSplitViewController, it is not recommended. The system implementation of the sidebar involves significant unseen complexity, including interlayering with scroll edge effects and fullscreen behaviors. NSSplitViewController provides the necessary level of abstraction for the framework to handle these details correctly. Regarding the SceneDelagate and scene based life-cycle, I would like to confirm that AppDelegate is not going away. Also if the above is a correct understanding, is there any advice as to what should, and should not, be moved to the SceneDelegate? UIApplicationDelegate is not going away and still serves a purpose for application-level interactions with the system and managing scenes at a higher level. Move code related to your app's scene or UI into the UISceneDelegate. Remember that adopting scenes doesn't necessarily mean supporting multiple scenes; an app can be scene-based but still support only one scene. Refer to the tech note Migrating to the UIKit scene-based life cycle and the Make your UIKit app more flexible WWDC25 session for more information.
Topic: UI Frameworks SubTopic: General
0
0
688
Jun ’25
iOS 26 + UINavigationBar crash in layoutSubViews - new observation tracking
My #1 crash report since iOS 26 is the following: 1 libobjc.A.dylib objc_exception_throw 2 Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 3 UIKitCore -[UINavigationBar layoutSubviews] 4 UIKitCore UIView._layoutSubviewsWithObservationTracking() 5 UIKitCore @objc UIView._layoutSubviewsWithObservationTracking() Thread 0 9 libobjc.A.dylib objc_exception_throw 10 Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 11 UIKitCore -[UINavigationBar layoutSubviews] 12 UIKitCore UIView._layoutSubviewsWithObservationTracking() 13 UIKitCore @objc UIView._layoutSubviewsWithObservationTracking() I tried many things, without success so far. It seemed related to the new view update with observation tracking: link to documentation Any lead on how I should investigate this? Many thanks in advance!!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
7
2h
Setting `navigationItem.standardAppearance` overrides backButtonImage setting
Hello everybody. I need your help with configuring navigationItem properly. I want to use its appearance properties to configure how the navigation bar looks on per-screen basis without interacting with UINavigationBar directly (the API has been implemented for this specific use case, right?) What I'm confused about is that setting any appearance property resets back button image to the default chevron. What I do now: Inside my app delegate let navigationBarAppearance = UINavigationBar.appearance() navigationBarAppearance.backIndicatorImage = UIImage() navigationBarAppearance.backIndicatorTransitionMaskImage = UIImage() I do this to hide the default chevron to customize back button appearance on per-view-controller basis Then in my presenting view controller: override func viewDidLoad() { super.viewDidLoad() navigationItem.title = "Root" navigationItem.backBarButtonItem = UIBarButtonItem( title: nil, image: nil, primaryAction: UIAction( title: "", image: UIImage(systemName: "square.and.arrow.up"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .on, handler: { [weak self] _ in self?.navigationController?.popViewController(animated: true) } ), menu: nil ) let appearance = UINavigationBarAppearance() appearance.configureWithTransparentBackground() appearance.backgroundColor = UIColor.red appearance.titleTextAttributes = [ .foregroundColor: UIColor.purple ] appearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.purple ] navigationItem.standardAppearance = appearance navigationItem.compactAppearance = appearance navigationItem.scrollEdgeAppearance = appearance navigationItem.compactScrollEdgeAppearance = appearance } The colors are set up as expected, however the default chevron image appears on the next view controller next to square.and.arrow.up. If I don't touch navigation item appearance properties - only square.and.arrow.up is displayed, as I want, but obviously I loose all the customization. Can anyone please explain how to set things up properly? Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
9
2h
AppIntents default value
Hi, I have created an AppIntent in which there is a parameter called price, I have set the default value as 0. @Parameter(title: "Price", default: 0) var price: Int Problem When the shortcut is run this parameter is skipped Aim I still want to price to be asked however it needs to be pre-filled with 0 Question What should I do that the shortcut can still ask the price but be pre-filled with 0?
0
0
30
6h
AppIntents
Overview I have a custom type Statistics that has 3 properties inside it I am trying to return this as part of the AppIntent's perforrm method struct Statistics { var countA: Int var countB: Int var countC: Int } I would like to implement the AppIntent to return Statistics as follows: func perform() async throws -> some IntentResult & ReturnsValue<Statistics> { ... ... } Problem It doesn't make much sense to make Statistics as an AppEntity as this is only computed as a result. Statistics doesn't exist as a persisted entity in the app. Questions How can I implement Statistics? Does it have to be AppEntity (I am trying to avoid this)? (defaultQuery would never be used.) What is the correct way tackle this?
0
0
42
7h
SwiftUI ScrollView blocked when content contains a drag gesture
I am porting my app to SwiftUI and I am hitting a wall when using ScrollView. In my application, I have nested scrollViews to represent a scheduler. outer vertical scroll view inner horizontal scroll view that allows to horizontally scroll multiple columns in the scheduler each column in the inner scroll view is a view that needs to allow for a drag to initiate the creation of a new appointment on macOS, I do a mouse-down drag, so it does not affect the scroll view and works fine on iOS, if I add a drag gesture to the column, it short circuits the scroll view and scrolling becomes disabled. To initiate the drag, there is a long-press, and that gesture is fine, only the subsequent drag gesture is problematic. I have attached URL to a test app. The UI allows you to toggle the drag gesture. Hopefully, someone can help to get it to work since I would eventually like to port the macOS target to Catalyst. Download Test App
Topic: UI Frameworks SubTopic: SwiftUI
1
0
115
1d
SwiftUI List cell reuse / view lifecycle behavior when scrolling
I’m trying to understand how SwiftUI List handles row lifecycle and reuse during scrolling. I have a list with around 60 card views; on initial load, only about 7 rows are created, but after scrolling to the bottom all rows appear to be created, and when scrolling back to the top I again observe multiple updates and apparent re-creation of rows. I confirmed this behavior using Instruments by profiling my app. Even though each row has a stable identifier, the row views still seem to be destroyed and recreated, which doesn’t resemble UIKit’s cell reuse model. I’d like clarity on how List uses identifiers internally, what actually gets reused versus recreated, and how developers should reason about performance and view lifetime in this case.
0
1
39
1d
MacCatalyst and the User's Documents Folder
I have a SwiftUI-based universal app which creates a file that it stores in documentsDirectory. On iOS/iPadOS, this file is stored in the application's Documents directory and is accessible via the Files app. On MacCatalyst, this operation does the same thing — it creates the file and stores it in ~/Library/Containers/<app directory>/Data/Documents. However what I want is for the document to be stored in ~/Documents, so that it is easily accessible to the user. How can I do that? I'd like it to occur without (for example) having to show a SaveFile panel...
3
0
197
1d
listRowBackground vs swipeActions ios26 compatibility
Hi! On iOS 26, Apple’s Mail app shows an effect where a list row gets rounded corners while you’re swiping (so the row visually “matches” the rounded swipe buttons). In my app I’m using SwiftUI List + .swipeActions. I also need a custom row tint (e.g. subtle red/gray highlight based on state). The problem is: If I apply my tint using .background / .clipShape, it moves with the row content during swipe and looks wrong. If I use .listRowBackground(...), I keep the tint, but I don’t get the same rounded-corners “morphing” effect as in Mail (or it looks inconsistent). Question: What’s the correct way in iOS 26 to keep a custom row tint and get the system-style rounded corners / liquid-glass effect while swiping?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
49
2d
Why is ScreenCaptureKit throttled to about 7 fps?
I have an app that records a 32 x 32 rect under the cursor as the user moves it around and it sends it to Flutter. It suffers from major lag. Instead of getting 30 fps, I get about 7 fps. That is, there are significant lags between screen grabs. This on an Intel Mac mini x64 with 15.7.3 and one display. flutter: NATIVE: ExplodedView framesIn=2 timeSinceStart=1115.7ms gapSinceLastFrame=838.8ms flutter: NATIVE: ExplodedView framesIn=4 timeSinceStart=1382.6ms gapSinceLastFrame=149.9ms flutter: NATIVE: ExplodedView framesIn=5 timeSinceStart=1511.0ms gapSinceLastFrame=128.4ms flutter: NATIVE: ExplodedView framesIn=7 timeSinceStart=1698.3ms gapSinceLastFrame=102.9ms flutter: NATIVE: ExplodedView STOP polling totalTime=4482.6ms framesIn=28 framesSent=28 acks=28 Here's a testable excerpt: import ScreenCaptureKit import CoreMedia import CoreVideo import QuartzCore final class Test: NSObject, SCStreamOutput, SCStreamDelegate { private let q = DispatchQueue(label: "cap.q") private var stream: SCStream? private var lastFrameAt: CFTimeInterval = 0 private var frames = 0 func start() { SCShareableContent.getExcludingDesktopWindows(false, onScreenWindowsOnly: true) { content, err in guard err == nil, let display = content?.displays.first else { print("shareableContent error: \(String(describing: err))"); return } let filter = SCContentFilter(display: display, excludingWindows: []) let config = SCStreamConfiguration() config.showsCursor = false config.queueDepth = 1 config.minimumFrameInterval = CMTime(value: 1, timescale: 30) config.pixelFormat = kCVPixelFormatType_32BGRA config.width = 32 config.height = 32 config.sourceRect = CGRect(x: 100, y: 100, width: 32, height: 32) let s = SCStream(filter: filter, configuration: config, delegate: self) try! s.addStreamOutput(self, type: .screen, sampleHandlerQueue: self.q) self.stream = s s.startCapture { startErr in print("startCapture err=\(String(describing: startErr))") } // Optional: move sourceRect at 30Hz (cursor-follow simulation) Timer.scheduledTimer(withTimeInterval: 1.0/30.0, repeats: true) { _ in let c2 = SCStreamConfiguration() c2.showsCursor = false c2.queueDepth = 1 c2.minimumFrameInterval = CMTime(value: 1, timescale: 30) c2.pixelFormat = kCVPixelFormatType_32BGRA c2.width = 32 c2.height = 32 let t = CACurrentMediaTime() c2.sourceRect = CGRect(x: 100 + (sin(t) * 50), y: 100, width: 32, height: 32) s.updateConfiguration(c2) { _ in } } } } func stream(_ stream: SCStream, didOutputSampleBuffer sb: CMSampleBuffer, of type: SCStreamOutputType) { guard type == .screen else { return } let now = CACurrentMediaTime() let gapMs = (lastFrameAt == 0) ? 0 : (now - lastFrameAt) * 1000 lastFrameAt = now frames += 1 if frames <= 10 || frames % 60 == 0 { print("frames=\(frames) gapMs=\(String(format: "%.1f", gapMs))") } } }
0
0
91
2d
UICollectionView cells don't show accessibility numbers or labels
I started to use the Accessibility features of UIKit but cannot get the numbers or labels to show up on UICollectionCells. The image here shows a 3x3 matrix with no numbers, but the numbers on the menu commands show up. Actually these are just iOS accessibility features, not my app. I've tried reducing the size of my images or no images, but nothing shows up (in any of my UICollection code). I can get them to work on UITableView cells. I've tried the Accessibility selection in the storyboard or code, but nothing helps.
0
0
111
4d
Navigation title flickers when tab is changed when used with a List / Form
Problem When a List / Form is added inside a TabView and navigationTitle is set, then switching between tabs causes the navigation title to flicker. Feedback: FB21436493 Environment Xcode: 26.2 (17C52) iOS: 26.2 (23C55) Reproducible on: Both simulator and device Root cause When List / Form is commented out, issue doesn't occur Steps to Reproduce Run app on iOS Switch between tabs Notice that the navigation title flickers Code ContentView import SwiftUI struct ContentView: View { @State private var selectedTab = TabItem.red var body: some View { NavigationStack { TabView(selection: $selectedTab) { ForEach(TabItem.allCases, id: \.self) { tab in Tab(tab.rawValue, systemImage: tab.systemImageName , value: tab) { // Problem occurs with a List / Form // Commenting out list works without flickering title List { Text(tab.rawValue) } } } } .navigationTitle(selectedTab.rawValue) } } } TabItem enum TabItem: String, CaseIterable { case red case green case blue var systemImageName: String { switch self { case .red: "car" case .green: "leaf" case .blue: "bus" } } } Screen recording:
Topic: UI Frameworks SubTopic: SwiftUI
3
0
249
3d
DMG - Background - Broken in Tahoe ?
I am trying to set an image as the background in the window of a DMG. The image is: PNG file; 144x144 resolution; 1138x574 size. In macOS Tahoe, the image is added by: selecting the DMG window; opening the "Show View Options" dialog; clicking on "Picture"; dragging the image file to the small square box labelled "Drag image here"; closing "Show View Options" dialog. The DMG is then ejected. In Disk Utility, the image file is converted to "Read Only image (UDRO)". The converted image file is opened and the background image is visible. The image file is then copied to a MacBook running macOS 12 Monterey and opened. The background image is NOT shown. The image file is copied to a Mac mini running macOS 14 Sequoia and opened. The background image is NOT shown. Have read past online discussions in which it was explained that an image file called "background" should be inside a hidden folder called ".background". The above procedure did not do that. Is that old advice still correct for macOS Tahoe ? Has Tahoe somehow broken the method used for setting the background of a Window ? Is the method used in Tahoe different to past versions of macOS ? If so, is there a way of maintaining compatibility with old versions of macOS ? Is there any documentation on how to set the background image of a DMG window which might explain this behaviour ?? Thanks.
Topic: UI Frameworks SubTopic: General Tags:
0
0
87
4d
In Mac app, when the Settings view that uses `@Environment(\.dismiss)` it causes the subview's models to be created multiple times.
Problem For a mac app, when the Settings view that uses @Environment(\.dismiss) it causes the subview's models to be created multiple times. Environment macOS: 26.2 (25C56) Feedback FB21424864 Code App @main struct DismissBugApp: App { var body: some Scene { WindowGroup { ContentView() } Settings { SettingsView() } } } ContentView struct ContentView: View { var body: some View { Text("Content") } } SettingsView struct SettingsView: View { @Environment(\.dismiss) private var dismiss var body: some View { VStack { Text("Settings") SectionAView() } } } SectionAView struct SectionAView: View { @State private var model = SectionAViewModel() var body: some View { Text("A") .padding(40) } } SectionAViewModel @Observable class SectionAViewModel { init() { print("SectionAViewModel - init") } deinit { print("SectionAViewModel - deinit") } } Steps to reproduce (refer to the attached video) 1 - Run the app on the mac 2 - Open app's Settings 3 - Notice the following logs being printed in the console: SectionAViewModel - init SectionAViewModel - init 4 - Tap on some other app, so that the app loses focus 5 - Notice the following logs being printed in the console: SectionAViewModel - init SectionAViewModel - deinit 6 - Bring the app back to focus 7 - Notice the following logs being printed in the console: SectionAViewModel - init SectionAViewModel - deinit Refer to screen recording
Topic: UI Frameworks SubTopic: SwiftUI
0
0
160
5d
Using Content Inset Adjustments on macOS Tahoe with Liquid Glass in nested NSScrollViews inside Sidebar
I have the following code (compile as a standalone file): #import <Cocoa/Cocoa.h> @interface AppDelegate : NSObject <NSApplicationDelegate> @property (strong) NSWindow *window; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { // Create main window self.window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 800, 600) styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable) backing:NSBackingStoreBuffered defer:NO]; [self.window setTitle:@"Nested ScrollView Demo"]; [self.window makeKeyAndOrderFront:nil]; // Split view controller NSSplitViewController *splitVC = [[NSSplitViewController alloc] init]; // Sidebar NSViewController *sidebarVC = [[NSViewController alloc] init]; sidebarVC.view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 600)]; sidebarVC.view.wantsLayer = YES; NSSplitViewItem *sidebarItem = [NSSplitViewItem sidebarWithViewController:sidebarVC]; sidebarItem.minimumThickness = 150; sidebarItem.maximumThickness = 400; [splitVC addSplitViewItem:sidebarItem]; // Content view controller NSViewController *contentVC = [[NSViewController alloc] init]; // Vertical scroll view (outer) NSScrollView *verticalScrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 600, 600)]; verticalScrollView.automaticallyAdjustsContentInsets = YES; verticalScrollView.hasVerticalScroller = YES; verticalScrollView.hasHorizontalScroller = NO; verticalScrollView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; NSView *verticalContent = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 600, 1200)]; verticalContent.wantsLayer = YES; verticalContent.layer.backgroundColor = [[NSColor blueColor] CGColor]; [verticalScrollView setDocumentView:verticalContent]; // Add several horizontal scroll sections CGFloat sectionHeight = 150; for (int i = 0; i < 5; i++) { // Horizontal scroll view inside section NSScrollView *horizontalScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, verticalContent.frame.size.height - (i+1)*sectionHeight - i*20, 600, sectionHeight)]; horizontalScroll.hasHorizontalScroller = YES; horizontalScroll.hasVerticalScroller = NO; horizontalScroll.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; NSView *horizontalContent = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 1200, sectionHeight)]; horizontalContent.wantsLayer = YES; // Add labels horizontally for (int j = 0; j < 6; j++) { NSTextField *label = [NSTextField labelWithString:[NSString stringWithFormat:@"Item %d-%d", i+1, j+1]]; label.frame = NSMakeRect(20 + j*200, sectionHeight/2 - 15, 180, 30); [horizontalContent addSubview:label]; } horizontalScroll.documentView = horizontalContent; [verticalContent addSubview:horizontalScroll]; } contentVC.view = verticalScrollView; NSSplitViewItem *contentItem = [NSSplitViewItem splitViewItemWithViewController:contentVC]; contentItem.automaticallyAdjustsSafeAreaInsets = YES; contentItem.minimumThickness = 300; [splitVC addSplitViewItem:contentItem]; self.window.contentViewController = splitVC; // Sidebar label NSTextField *label = [NSTextField labelWithString:@"Sidebar"]; label.translatesAutoresizingMaskIntoConstraints = NO; [sidebarVC.view addSubview:label]; [NSLayoutConstraint activateConstraints:@[ [label.centerXAnchor constraintEqualToAnchor:sidebarVC.view.centerXAnchor], [label.centerYAnchor constraintEqualToAnchor:sidebarVC.view.centerYAnchor] ]]; } @end int main(int argc, const char * argv[]) { @autoreleasepool { NSApplication *app = [NSApplication sharedApplication]; AppDelegate *delegate = [[AppDelegate alloc] init]; [app setDelegate:delegate]; [app run]; } return 0; } Obviously, since the contents of the right part (the content of the sidebar) has its content inset, the horizontal scrolling views cannot extend to the left beneath the sidebar. I can change line 39 to say verticalScrollView.automaticallyAdjustsContentInsets = NO; which will make the inner horizontal scroll views able to extend below the sidebar, but then I'd lose out on the automatic inset management to not have other content overlap beneath the sidebar. So what can I do here? I've tried manually changing the frame of the inner scroll views to start on a negative x, but that does not allow me to scroll all the way to the leftmost content. I'm hoping I won't have to adjust for safe areas manually for the outer scroll view. I'd also appreciate tips on how to fix the fact that veritical scrolling doesn't work when your mouse is in a horizontal scroll view. Thanks! P.S. same thing also exists on UIKit.
0
0
110
6d
SwiftUI @State Updates Not Reflecting in UI Until View Reconstruction (Xcode Preview & Device)
Issue Description I'm experiencing a bizarre SwiftUI state update issue that only occurs in Xcode development environment (both Canvas preview and device debugging), but does not occur in production builds downloaded from App Store. Symptom: User taps a button that modifies a @State variable inside a .sheet Console logs confirm the state HAS changed But the UI does not update to reflect the new state Switching to another file in Xcode and back to ContentView instantly fixes the issue The production build (same code) works perfectly fine Environment Xcode: 16F6 (17C52) iOS: 26.2 (testing on iPhone 13) macOS: 25.1.0 (Sequoia) SwiftUI Target: iOS 15.6+ Issue: Present in both Xcode Canvas and on-device debugging Production: Same code works correctly in App Store build (version 1.3.2) Code Structure Parent View (ContentView.swift) struct ContentView: View { @State private var selectedSound: SoundTheme = .none @State private var showSoundSheet = false var body: some View { VStack { // Display button shows current selection SettingButton( title: "Background Sound", value: getLocalizedSoundName(selectedSound) // ← Not updating ) { showSoundSheet = true } } .sheet(isPresented: $showSoundSheet) { soundSelectionView } } private var soundSelectionView: some View { ForEach(SoundTheme.allCases) { sound in Button { selectedSound = sound // ← State DOES change (confirmed in console) // Audio starts playing correctly audioManager.startAmbientSound(sound) } label: { Text(sound.name) } } } private func getLocalizedSoundName(_ sound: SoundTheme) -> String { // Returns localized name return sound.localizedName }} What I've Tried Attempt 1: Adding .id() modifier SettingButton(...) .id(selectedSound) // Force re-render when state changes Result: No effect Attempt 2: Moving state modification outside withAnimation // Before (had animation wrapper):withAnimation { selectedSound = sound}// After (removed animation):selectedSound = sound Result: No effect Attempt 3: Adding debug print() statements selectedSound = soundprint("State changed: (selectedSound)") // ← Adding this line FIXES the issue! Result: Mysteriously fixes the issue! But removing print() breaks it again. This suggests a timing/synchronization issue in Xcode's preview system. Observations What works: ✅ Console logs confirm state changes correctly ✅ Switching files in Xcode triggers view reconstruction → everything works ✅ Production build from App Store works perfectly ✅ Adding print() statements "fixes" it (likely changes execution timing) What doesn't work: ❌ Initial file load in Xcode ❌ Hot reload / incremental updates ❌ Both Canvas preview and on-device debugging Workaround that works: Click another file in Xcode Click back to ContentView.swift Everything works normally Key Question Is this a known issue with Xcode 16's SwiftUI preview/hot reload system? The fact that: Same exact code works in production Adding print() "fixes" it File switching triggers reconstruction that fixes it ...all suggest this is an Xcode tooling issue, not a code bug. However, it makes development extremely difficult as I can't reliably test changes without constantly switching files or killing the app. What I'm Looking For Confirmation: Is this a known Xcode 16 issue? Workaround: Any better solution than constantly switching files? Root cause: What's causing this state update timing issue? Any insights would be greatly appreciated!
Topic: UI Frameworks SubTopic: SwiftUI
6
0
335
5d
What is the best way to push iOS26 List content up on TextField keyboard focused?
Code example: // // ListSafeAreaBarKeyboardTextField.swift // Exploration import SwiftUI import Foundation struct ListSafeAreaBarKeyboardTextField: View { @State private var typedText: String = "" @FocusState private var focusingTextField: Bool private let items = Array(1...16) var body: some View { ScrollViewReader { proxy in List(items, id: \.self) { number in Text("Item \(number)") .id(number) } .onAppear { if let lastItem = items.last { proxy.scrollTo(lastItem, anchor: .bottom) } } .onChange(of: focusingTextField) { oldValue, newValue in // This simply won't work // ~ 12th - 16th item will still get covered by keyboard if newValue == true { // Delay to allow keyboard animation to complete DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { if let lastItem = items.last { withAnimation { proxy.scrollTo(lastItem, anchor: .top) } } } } } } .scrollDismissesKeyboard(.interactively) .safeAreaBar(edge: .bottom) { TextField("Type here", text: $typedText, axis: .vertical) .focused($focusingTextField) // Design .padding(.horizontal, 16) .padding(.vertical, 10) .glassEffect() // Paddings .padding(.horizontal, 24) .padding(.vertical, 12) } } }
1
0
108
1w
Changes in Mouse Event Reporting Frequency in macOS 26.2
I have a Mac application that uses the NSEvent.addLocalMonitorForEvents API to receive all mouse movement events. It receives all the mouse movement events and calculate the event reporting rate. The code used as following: import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } .frame(width: 400, height: 400) .padding() .onAppear() { // here NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) { event in print(event.timestamp) return event } } } } With the exact same code, before I upgraded my macOS to the latest version 26.2, I could receive approximately 460+ mouse events per second, this matched the hardware reporting frequency of my mouse device perfectly. However, after upgrading to version 26.2, I noticed that the number of mouse events received per second is limited to match the screen refresh rate: when I set the screen refresh rate to 60Hz, I only receive 60 mouse events per second; when set to 120Hz, I receive 120 events per second. It is clear that some changes has be delivered in macOS 26.2, which by default downsamples the frequency of mouse events reported to applications to align with the screen refresh rate. The question is how can I reteive all the original mouse events in macOS 26.2? I tried to search and dig, bug no any related APIs found.
Topic: UI Frameworks SubTopic: AppKit
0
0
106
1w
ToolbarItem with .sharedBackgroundVisibility(.hidden) causes rectangular rendering artifact during navigation transitions on iOS 26
Description: When following Apple's WWDC guidance to hide the default Liquid Glass background on a ToolbarItem using .sharedBackgroundVisibility(.hidden) and draw a custom circular progress ring, a rectangular rendering artifact appears during navigation bar transition animations (e.g., when the navigation bar dims/fades during a push/pop transition). Steps to Reproduce: Create a ToolbarItem with a custom circular view (e.g., a progress ring using Circle().trim().stroke()). Apply .sharedBackgroundVisibility(.hidden) to hide the default Liquid Glass background. Navigate to a detail view (triggering a navigation bar transition animation). Observe the ToolbarItem during the transition. Expected Result: The custom circular view should transition smoothly without any visual artifacts. Actual Result: A rectangular bounding box artifact briefly appears around the custom view during the navigation bar's dimming/transition animation. The artifact disappears after the transition completes. Attempts to Resolve (All Failed): Using .frame(width: 44, height: 44) with .aspectRatio(1, contentMode: .fit) Using .fixedSize() instead of explicit frame Using Circle().fill() as a base view with .overlay for content Using Button with .buttonStyle(.plain) and Color.clear placeholder Various combinations of .clipShape(Circle()), .contentShape(Circle()), .mask(Circle()) Workaround Found (Trade-off): Removing .sharedBackgroundVisibility(.hidden) eliminates the rectangular artifact, but this prevents customizing the Liquid Glass appearance as intended by the API. Code Sample: swift if #available(iOS 26.0, *) { ToolbarItem { Button { // action } label: { Color.clear .frame(width: 32, height: 32) .overlay { ZStack { // Background arc (3/4 circle) Circle() .trim(from: 0, to: 0.75) .stroke(Color.blue.opacity(0.3), style: StrokeStyle(lineWidth: 4, lineCap: .round)) .rotationEffect(.degrees(135)) .frame(width: 28, height: 28) // Progress arc Circle() .trim(from: 0, to: 0.5) // Example: 50% progress .stroke(Color.blue, style: StrokeStyle(lineWidth: 4, lineCap: .round)) .rotationEffect(.degrees(135)) .frame(width: 28, height: 28) Text("50") .font(.system(size: 12, weight: .bold)) .foregroundStyle(Color.blue) Text("100") .font(.system(size: 8, weight: .bold)) .foregroundStyle(.primary) .offset(y: 12) } .background { Circle() .fill(.clear) .glassEffect(.clear.interactive(), in: Circle()) } } } .buttonStyle(.plain) } .sharedBackgroundVisibility(.hidden) // ⚠️ This modifier causes the rectangular artifact during transitions } Environment: iOS 26 Beta
Topic: UI Frameworks SubTopic: SwiftUI
1
1
97
6d
VisionKit adds unexpected extra space above “Retake / Keep” controls after scanning
We are facing a UI layout issue while using VisionKit (VNDocumentCameraViewController) for document scanning. After capturing a document, an unexpected extra blank space appears above the “Retake” and “Keep” action bar also in Bottom. This extra space is not part of our custom UI and seems to be introduced by VisionKit itself. This issue impacts the final scan preview layout and reduces usable screen space, especially noticeable on devices all the device iPhone or iPad
0
0
22
1w