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

NSButton added/removed in a window leaks ~12 NSKeyValueDependency + block objects per button (macOS 26.5.1)
Adding and removing NSButton (any NSControl) in a window leaks AppKit-internal objects. A plain NSView does not. Environment: macOS 26.5.1 (25F80), Apple silicon (arm64), Swift, swiftc -O, no third-party code. Repro (single file): import AppKit func mb()->Int{ var i=task_vm_info_data_t(); var c=mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size/4); withUnsafeMutablePointer(to:&i){ $0.withMemoryRebound(to:integer_t.self,capacity:1){ _=task_info(mach_task_self_,task_flavor_t(TASK_VM_INFO),$0,&c)}}; return Int(i.phys_footprint/1048576)} let app = NSApplication.shared; app.setActivationPolicy(.accessory) let mode=CommandLine.arguments[1] let win=NSWindow(contentRect:NSRect(x:100,y:100,width:400,height:100),styleMask:[.titled],backing:.buffered,defer:false) let stack=NSStackView(); win.contentView=stack; win.orderFrontRegardless() var n=0 print(mode,"start",mb()); fflush(stdout) Timer.scheduledTimer(withTimeInterval:0.002,repeats:true){ t in autoreleasepool { for v in stack.arrangedSubviews { stack.removeArrangedSubview(v); v.removeFromSuperview() } for _ in 0..<10 { let b: NSView = mode=="view" ? NSView(frame:.zero) : NSButton(title:"", target:nil, action:nil) if mode=="plainadd" { win.contentView!.addSubview(b); b.removeFromSuperview() } else { stack.addArrangedSubview(b) } } } n+=1 if n%500==0 { print(mode,"iter",n*10,mb()); fflush(stdout) } if n>=2500 { t.invalidate() } } app.run()swiftc -O repro.swift -o tw ./tw button & # then: heap $(pgrep -x tw) -s | grep -E "NSKeyValueDependency |__NSMallocBlock__|NSButton " ./tw view & # control case: plain NSViewResults (25,000 buttons created and removed; only 10 alive at a time): modefootprint (MB) at 5k / 15k / 25kNSKeyValueDependencyNSMallocBlockbutton (NSButton in NSStackView)26 / 43 / 60 (steady growth)292,621251,145view (plain NSView)flat at 13172n/aheap shows only 10 live NSButton instances, so the buttons themselves are freed. leaks reports no leaks, so AppKit still holds references to the objects. That is about 12 objects (~3 KB) per button. Allocation stack (MallocStackLogging=1 + malloc_history -callTree NSKeyValueDependency, taken on my real app): -[NSStackView insertArrangedSubview:atIndex:] -[NSView addSubview:] -[NSView _setSuperview:] -[NSView(NSViewRoot) _updateViewRoot] -[NSControl _viewRootDidChange] -[NSControl _setupGestureRecognizers] __cons_NSDP_NSDPTypeBool_block_invoke.273 NSDP_getComputedPropertyValue -[NSKeyValueDependencyInfo addDependencyInContext:onValueForKey:] _objc_rootAllocWithZoneThe allocation happens when an NSControl is added to a view hierarchy that has a window (_viewRootDidChange → _setupGestureRecognizers). The KVO dependency objects are never released after the control is removed and deallocated. Real-world impact: an app rebuilt about 40 buttons every 5 s. That leaked about 40 objects per second (~16 MB/hour). After 19 days it reached 7.2 GB footprint, mostly small malloc blocks, with ~1.4M NSKeyValueDependency objects and ~1.4M blocks. Questions: Is this a known issue? Is there a Feedback number? Is there a supported way to avoid or release these dependency objects, other than not recreating NSControls? Does it reproduce on macOS 26.x or 27 betas? Workaround for now: reuse buttons and only rebuild when state actually changes.
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
74
2w
iOS 27: app is not made inactive while the ATT prompt (or other permission alerts) is shown (FB25446786)
Since iOS 27, showing a system permission alert no longer deactivates the app. On iOS 26, sceneWillResignActive / applicationWillResignActive arrive about 0.05–0.1 s after ATTrackingManager.requestTrackingAuthorization. On iOS 27.0, 27.0.1 and 27.2 they don't arrive at all while the prompt is up, and SwiftUI's scenePhase stays .active. Apps that pause on resign, like games (Unity's iOS player pauses only on applicationWillResignActive), keep running behind the prompt: tutorials start, and timers and audio keep going. Minimal repro (plain UIKit with UIScene, fresh install so the status is .notDetermined): private var askedForTracking = false func sceneDidBecomeActive(_ scene: UIScene) { print("sceneDidBecomeActive") guard !askedForTracking else { return } askedForTracking = true DispatchQueue.main.asyncAfter(deadline: .now() + 3) { print("requesting ATT") ATTrackingManager.requestTrackingAuthorization { status in print("ATT finished: \(status.rawValue)") } } } func sceneWillResignActive(_ scene: UIScene) { print("sceneWillResignActive") }iOS 26.6: 3.27s requesting ATT 3.35s willResignActive 16.81s ATT finished: authorized 17.24s didBecomeActiveiOS 27.2: 3.21s requesting ATT 16.88s ATT finished: authorized 17.32s willResignActive 17.33s didBecomeActiveSo on iOS 27 the only lifecycle events are a resign/active pair about 0.44 s after the answer. What we found: The camera and notification permission alerts behave the same. It doesn't depend on the SDK the app is linked against, or on the thread making the request. SpringBoard's log shows the systemModalAlert deactivation assertion being added, but on iOS 27 the updateAllScenesForBand - Assertion added update never reaches the app's scene. The pending reason is only applied on the next unrelated scene update, such as a notification banner arriving, the screen dimming, an unlock, or the alert being dismissed. Taps outside the alert, a Control Center swipe or a home-indicator drag don't trigger it. Filed as FB25446786, with a sample project, delay sweeps on iOS 26 vs 27 (simulator and device) and a sysdiagnose. Is anyone else seeing this? And is there a supported way to know a permission alert is on screen until it's fixed? If you're affected, please file a Feedback and mention FB25446786; duplicates help.
0
0
81
2w
Issue: Screen rotation becomes locked when updating the status bar on an iPhone Duo.
Issue: Screen rotation becomes locked when updating the status bar on an iPhone Duo. This does not appear to be a device-specific hardware issue; however, it occurs specifically on the iPhone Duo. In my app, if I change the status bar visibility (using prefersStatusBarHidden) while on the iPhone Duo’s external screen, and then immediately unfold the device to reveal the internal screen, the app’s rotation state becomes locked. Although I use prefersInterfaceOrientationLocked to manage rotation, the app remains locked even when this property returns false. The issue persists even when prefersInterfaceOrientationLocked is commented out or removed entirely. Returning to the device’s home screen, rotating the device, and then re-entering the app resolves the lock. Has anyone encountered or resolved a similar issue?
0
0
83
2w
How to get UIInputView to appear with same height as standard keyboard?
I'm creating a custom keyboard by subclassing UIInputView. This is set as a text field's inputView property. This is a simple keypad similar to the standard numeric keypad keyboard. In fact, my UI lets the user switch between the standard numeric keypad and my custom input view. Given this it would be very nice if my custom input view was the same height as the standard keypad. If there a proper way to subclass UIInputView such that its height is the same "standard" height as the numeric keypad when run on any iOS device from iOS 17 through 27.3? I do not want to have to hardcode dozens of heights for every model iPhone and iPad, not to mention the 5 different heights you get on the iPhone Duo. I've tried various combinations of setting allowsSelfSizing to true and false along with returning a height of UIView.noIntrinsicMetric in intrinsicContentSize as well as not setting intrinsicContentSize at all. The closest result is when allowsSelfSizing is set to false. In that case my custom input view's height is somewhat similar to the standard keypad but in some cases it's off by 20-30 points roughly. Has anyone implemented a custom UIInputView that gets the standard keyboard height without hardcoding device specific heights?
0
1
113
2w
CarPlay Video entitlement causes blank screen and no CPTemplateApplicationScene callbacks
I have CarPlay Video enabled for my account and App ID. I tested both my main app and a completely new minimal iOS app with a new Bundle ID. The minimal app only contains: UIApplicationDelegate CPTemplateApplicationScene configuration CPTemplateApplicationSceneDelegate A single CPListTemplate root Results: With com.apple.developer.carplay-audio only, CarPlay launches normally. When com.apple.developer.carplay-video is added, CarPlay opens a blank screen. No CarPlay callbacks are called: application(:configurationForConnecting:options:) CPTemplateApplicationSceneDelegate.templateApplicationScene(:didConnect:) CPApplicationDelegate.didConnectCarInterfaceController The signed app and embedded provisioning profile both contain com.apple.developer.carplay-video. Does CarPlay Video require an additional runtime allowlist, specific head unit support, a different scene configuration, or another entitlement beyond com.apple.developer.carplay-video?
5
1
1.1k
2w
UINavigationController, Nav Bar does not extend to top on iPhone Duo
When using a background color for a UINavigation controller it seems the header does not extend to the top of the device for iPhone Duo when its closed in portrait mode. See screenshot. It should fill the entire 'status' bar up to top of device, Landscape correctly works, its just Portrait. Any thoughts on if this is 'expected' behavior? Seems odd to not just extend the navbar alll the way to the top.
Topic: UI Frameworks SubTopic: UIKit Tags:
6
2
978
2w
iOS 26: FloatingBarContainerView overlapping the whole custom ViewController
Hi everyone: I'm experiencing an issue in iOS 26. I've implemented a custom ViewController. It's super simple to edit images with flip, crop, zoom in, and zoom out. My question is that it seems very strange to me. It works without problems in iOS 17.5 and iOS 18. However, when I try to run it with iOS 26, the entire ViewController seems disabled; it doesn't recognize touches or anything. When I checked the UI hierarchy, I saw a strange FloatingBarContainerView overlaying the entire ViewController. I searched the documentation for information about this view, but I couldn't find anything. Any help on how to hide or remove this view in iOS 26? This hasn't been implemented anywhere.
3
0
1.1k
2w
Finger input interrupted while drawing with Apple Pencil + palm resting on display
I’m investigating an issue with simultaneous Apple Pencil and finger input on iPad. Apple Pencil + finger input works correctly while the Pencil user’s hand/palm is off the display. However, when drawing naturally with Apple Pencil with the palm resting on the display, an existing finger drawing contact elsewhere on the screen can be cancelled and then stop receiving input for several seconds. Pencil input continues normally throughout. Initially I suspected PencilKit, but I’ve reproduced the underlying behaviour below PencilKit/SwiftUI. Instrumenting UIKit at UIApplication.sendEvent shows the finger touch being cancelled and, in some cases, no further events for that finger for ~4–5 seconds while Pencil MOVED events continue to arrive normally. Everything delivered to the application is accounted for, so this appears to occur before our drawing/rendering code. Is this expected behaviour from the iPad’s Pencil/palm rejection? More specifically: Is there any supported way to tell UIKit that an existing finger contact should remain intentional while Pencil + palm contact is present? Is palm rejection configurable at this level? Is there another public input API we should be using for this scenario? We’re currently testing UIEvent.coalescedTouches(for:) to determine whether additional genuine finger samples are available during these apparent gaps, but haven’t completed that test yet. Any guidance on whether this interaction is expected to be supportable through public UIKit APIs would be appreciated.
3
0
1.1k
2w
Keyboard Toolbar Padding iOS26
When I create a SwiftUI toolbar item with placement of .keyboard on iOS 26, the item appears directly on top of and in contact with the keyboard. This does not look good visually nor does it match the behavior seen in Apple's apps, such as Reminders. Adding padding to the contents of the toolbar item only expands the size of the item but does not separate the capsule background of the item from the keyboard. How can I add vertical padding or spacing to separate the toolbar item capsule from the keyboard?
Topic: UI Frameworks SubTopic: SwiftUI
15
9
2.4k
2w
iPhone Duo - Buggy margin shift while dragging down a modal view controller
Has anyone else run into this issue? If you present a view controller and set its isModalInPresentation property to true, then when you try to drag down the view controller (which can't be dismissed), the view controller's content on the side of the vertical toolbar is shifted inward. This happens on a closed iPhone Duo. Even the title shifts if the vertical toolbar is on the left side. To replicate, create a Swift/UIKit project. Edit the main storyboard by deleting the default view controller scene and add a navigation controller (and its default root view controller). Set the class for the root view controller to ViewController. Then replace the default ViewController.swift code with the following: import UIKit class ViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() let modal = UIBarButtonItem(systemItem: .add, primaryAction: .init(handler: { _ in let vc = ViewController() vc.title = "Some Modal" // If the following is true, dragging the modal view controller // down results in the table margins being shifted on whichever // side has a vertical toolbar. This happens on the iPhone Duo // when closed in either portrait or landscape. Whichever side // has the vertical toolbar gets shifted. // When the iPhone Duo is open the modal appears in a form sheet // and it does not demonstrate the issue. // The navigation title is also affected when the iPhone Duo is // closed and in landscape with the vertical toolbar on the left. // If the following is false, dismissing the modal by dragging it // down does NOT result in any change in the table's margins. vc.isModalInPresentation = true // false let nc = UINavigationController(rootViewController: vc) self.present(nc, animated: true) })) navigationItem.rightBarButtonItem = modal } } extension ViewController { override func numberOfSections(in tableView: UITableView) -> Int { 2 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 4 } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // Some simple table cells to demonstrate the margin shift let cell = tableView.dequeueReusableCell(withIdentifier: "cell") ?? UITableViewCell(style: .value1, reuseIdentifier: "cell") cell.textLabel?.text = "Some Text" cell.detailTextLabel?.text = "Value" cell.accessoryType = .disclosureIndicator return cell } } Build and run the app with Xcode 27.1 and run it on an iPhone Duo (simulated or real). Tap the + icon to display the modal view controller (just another instance of ViewController). Now try to drag down the modal view controller. Notice the margin shift if the Duo is closed. There is no margin shift is the Duo is open or if isModalInPresentation is set to false. This has been reported as FB25221160.
2
0
776
2w
Standard toolbar hidden below tab bar in iOS 27.x when running on iPhones
There have been report several issues with this configuration in very old iOS versions. From iOS 27 it seems to be a problem again, or? Assume you have a tab bar controller that contains one ore move navigation controllers. These navigation controllers have one view controller that adds buttons to the navigaton controller's toolbar. Running the app on an iPad, everything works well. Running it on an iPhone, the toolbar is hidden below the tab bar. Is there any workaround to fix this? PS: A simple scene file is attached that shows the issue.
Topic: UI Frameworks SubTopic: UIKit
0
0
50
2w
iOS 27: SwiftUI TextField text invisible while typing when the app runs in Arabic (FB25410049)
Since iOS 27, if an app runs in Arabic (or, presumably, any right-to-left language), typing digits or Latin letters into a SwiftUI TextField makes the field look empty. The binding updates and the caret shows, but the text isn't drawn until editing ends. What I measured: The text's layout fragment is placed at about x = −39,655 pt in a 370 pt wide field, so it's drawn far outside the field. A plain TextField and one with .environment(\.layoutDirection, .leftToRight) (phone and card numbers) are both affected. A UIKit UITextField on the same screen isn't affected. The same build on iOS 18.0 works, and iOS 27 in English works. Minimal repro: one SwiftUI file with four fields. Run it with App Language set to Arabic, tap the first field and type 523. Launch with -autoProbe to have it type into each field and print where the text was laid out. PROBE iOS 27.0, language ar, layout RTL PROBE field 1 text="523" fieldWidth=370 fragmentX=[-39655] visible=false // SwiftUI TextField PROBE field 2 text="523" fieldWidth=370 fragmentX=[-39655] visible=false // SwiftUI, LTR pinned PROBE field 3 text="523" fieldWidth=370 fragmentX=[314] visible=true // UIKit UITextFieldWorkaround that works for us, installed once at launch: import UIKit enum TextFieldDirection { static func install() { for name in [UITextField.textDidBeginEditingNotification, UITextField.textDidChangeNotification] { NotificationCenter.default.addObserver(forName: name, object: nil, queue: .main) { note in guard let field = note.object as? UITextField else { return } MainActor.assumeIsolated { settle(field) } // SwiftUI rebuilds the paragraph style right after; settle again. DispatchQueue.main.async { MainActor.assumeIsolated { settle(field) } } } } } @MainActor static func settle(_ field: UITextField) { let direction: NSWritingDirection = field.effectiveUserInterfaceLayoutDirection == .rightToLeft ? .rightToLeft : .leftToRight if let whole = field.textRange(from: field.beginningOfDocument, to: field.endOfDocument) { field.setBaseWritingDirection(direction, for: whole) } func directed(_ attributes: [NSAttributedString.Key: Any]) -> [NSAttributedString.Key: Any] { var attributes = attributes let style = (attributes[.paragraphStyle] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle ?? NSMutableParagraphStyle() style.baseWritingDirection = direction attributes[.paragraphStyle] = style return attributes } if let typing = field.typingAttributes { field.typingAttributes = directed(typing) } field.defaultTextAttributes = directed(field.defaultTextAttributes) field.setNeedsLayout() field.layoutIfNeeded() } }Don't pin textAlignment instead. SwiftUI puts .natural back on every keystroke and the caret jumps from side to side. If you see this too, please file a duplicate referencing FB25410049. Duplicates help Apple prioritise it.
1
0
119
2w
How do deal with NavigationSplitView not saving selection on iPhone
I have a detail view that has a @Binding var Thing, which is passed to it from the parent. It has TextFields that need to use that bound object's fields. // Using this to pass the selection around @Observable class AppSelection { var selectedThings:Set<Thing> = Set(); } struct ContentView: View { @State private var selectionStore = AppSelection(); var body: some View { NavigationSplitView { ... } content: { ...list that sets the selectionStore.selectedThings... } detail: { if !selectionStore.selectedThings.isEmpty { DetailView(thing:Binding( get: { selectionStore.selectedThings.first! }, // Crashes here set: { selectionStore.selectedThings = [$0] } )) .frame(maxHeight:.infinity, alignment:.top) } else { Text("Select a thing."); } } } } struct DetailView:View { @Binding var thing:Thing; var body:some View { TextField("Blah", $thing.name); TextField("Blerg", $thing.stuff); } }A crash happens when I navigate back from the DetailView in the line commented as such. I assume the NavigationSplitView is resetting the selection back to an empty state. Why the Binding given to the DetailView is even trying to get its value at that point is beyond me (so much weirdness in SwiftUI). I've taken so many different stabs at trying to make things work differently, but I just don't understand enough about SwiftUI. Like can I make the DetailView take an optional binding? If the Thing is nil, then all the TextFields complain that they require a non-optional binding. I don't even want to show the Detail view if nothing is selected (hence the "Select a thing.").
1
0
887
2w
iPhone Duo: Sidebar toolbar item becomes unreachable after rotating to portrait
On the unfolded iPhone Duo simulator, I can reach Settings through the toolbar overflow in landscape. After I rotate to portrait and open the floating sidebar, Settings disappears from both the toolbar and the available menus. I’ve seen this on iOS 27.1 and 27.2. I also reproduced it in a standalone UIKit app on iOS 27.2 and attached the Xcode project to Feedback Assistant report FB25402191. The standalone sample uses a two-column UISplitViewController with a UINavigationController in each column. The primary view controller assigns five actions to toolbarItems once in viewDidLoad, with Settings last. All five use the default visibility priority. The app makes no changes to its toolbar items during rotation. Steps to reproduce Fully unfold the simulated device and rotate to landscape with the detail pane’s vertical toolbar on the right. Widen the sidebar until all five buttons, including the Settings gear, appear in its bottom toolbar. Narrow the sidebar to about 280 points. Four buttons remain along the bottom. Open the ellipsis menu in the detail pane and tap Settings to confirm the action works. Keeping the device unfolded, rotate 90 degrees left into portrait. Tap the sidebar button to reveal the floating sidebar. I expected Settings to remain reachable through an overflow menu if the gear couldn’t fit. Instead, the floating sidebar shows four buttons, and neither pane offers an overflow menu containing Settings. The Settings item is still present in the primary view controller’s toolbarItems array. Rotating back to landscape makes it reachable again. Has anyone reproduced this on a physical iPhone Duo? Is there a supported way to keep an overflowed primary toolbar action accessible when the sidebar changes from a side-by-side column to a floating panel?
Topic: UI Frameworks SubTopic: UIKit
1
0
82
2w
iPhone Duo black bars in landscape on iOS 27.1
I am implementing support for iPhone Duo, and have seen this in many places: Apps built with the iOS 27.1 SDK or later are optimized for iPhone Duo. Apps will extend to use the full display, with toolbars and tab bars appearing vertically below the status bar. (from https://developer.apple.com/iphone-duo/prepare/) But when I build my application in Xcode 27.1, in both the simulator, and on the Duo hardware, my application is not extending to the full-width of the screen when built for iOS 27.1. There are black bars on both the left and right. When I debug the view hierarchy, I do not see the black bars, which indicates to me this is happening at the OS level, not as a result of my constraints. Note that there are no black bars in portrait mode, or on the front screen. In my project settings, only the iPhone Orientation "Portrait" is checked, but I don't want to check Landscape orientations there, because the application does not look good in landscape on a standard iPhone aspect ratio. Are those checkboxes required to remove the black bars? (Checking them does appear to do so, but again, this is quite problematic for the current design of the application.) Thanks in advance for any insights or help you can provide!
Topic: UI Frameworks SubTopic: UIKit
3
0
116
2w
No access to dictation from third-party keyboards on iPhone Duo
On a physical iPhone Duo running iOS 27.1 and later, the system dictation button is placed inside the system keyboard, next to the space bar. Because the button belongs to the system keyboard layout, it isn't available while a third-party keyboard is active. On other iPhone models, the dictation button appears separately from the keyboard, so it stays available with third-party keyboards. On iPhone Duo, our users have no way to start dictation without switching back to the system keyboard. The iPhone Duo Simulator shows the button at the far right, which doesn't match the physical device, so this can't be evaluated accurately in the Simulator. As far as I can tell, there is no public API that lets a keyboard extension start system dictation, so we can't work around this from the extension. My questions: Is this placement intended on iPhone Duo? Is there a supported way for a keyboard extension to offer dictation on this device? If not, are there plans for a separate system dictation button, as on other iPhone models, or a public API for keyboard extensions? I've filed this as FB[number]. If you develop a keyboard extension and see the same issue, please file your own report and reference this number.
1
0
129
2w
PDFView context menu: "Actual Size"
In a PDFView, the OS provides a context menu which contains (among other things) "Actual Size" zoom. This command wrongly displays the page at 1 point = 1 pixel. Traditionally on MacOS, "Actual Size" displays the page at 1 inch on page = 1 inch on screen, e.g. for a Letter page, 8.5 x 11 inches on the screen. (So the API needs to determine the display's pixel density to calculate the zoom size.) In Preview 11.0 on Os 27.2, "Actual Size" in the PDFView context menu and in the View menu both zoom to 1 point = 1 pixel. In Preview on Sequoia, Actual Size in the View menu displays at 1 inch = 1 inch, but the context menu gives 1 pt = 1px. (The latter presumably relying on the built-in context menu from PDFView.) Note that in Pages.app, Actual View gives the expected 1 inch = 1 inch on screen.
1
0
110
2w
`presentationPlacement(_:)` support on Catalyst
presentationPlacement(_:) is a great addition and brings us very close to being able to deprecate a custom side sheet we wrote, but one missing piece we found is that it isn't yet honored on Catalyst. It would be great if support for this could be added!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
46
Activity
2w
NSButton added/removed in a window leaks ~12 NSKeyValueDependency + block objects per button (macOS 26.5.1)
Adding and removing NSButton (any NSControl) in a window leaks AppKit-internal objects. A plain NSView does not. Environment: macOS 26.5.1 (25F80), Apple silicon (arm64), Swift, swiftc -O, no third-party code. Repro (single file): import AppKit func mb()->Int{ var i=task_vm_info_data_t(); var c=mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size/4); withUnsafeMutablePointer(to:&i){ $0.withMemoryRebound(to:integer_t.self,capacity:1){ _=task_info(mach_task_self_,task_flavor_t(TASK_VM_INFO),$0,&c)}}; return Int(i.phys_footprint/1048576)} let app = NSApplication.shared; app.setActivationPolicy(.accessory) let mode=CommandLine.arguments[1] let win=NSWindow(contentRect:NSRect(x:100,y:100,width:400,height:100),styleMask:[.titled],backing:.buffered,defer:false) let stack=NSStackView(); win.contentView=stack; win.orderFrontRegardless() var n=0 print(mode,"start",mb()); fflush(stdout) Timer.scheduledTimer(withTimeInterval:0.002,repeats:true){ t in autoreleasepool { for v in stack.arrangedSubviews { stack.removeArrangedSubview(v); v.removeFromSuperview() } for _ in 0..<10 { let b: NSView = mode=="view" ? NSView(frame:.zero) : NSButton(title:"", target:nil, action:nil) if mode=="plainadd" { win.contentView!.addSubview(b); b.removeFromSuperview() } else { stack.addArrangedSubview(b) } } } n+=1 if n%500==0 { print(mode,"iter",n*10,mb()); fflush(stdout) } if n>=2500 { t.invalidate() } } app.run()swiftc -O repro.swift -o tw ./tw button & # then: heap $(pgrep -x tw) -s | grep -E "NSKeyValueDependency |__NSMallocBlock__|NSButton " ./tw view & # control case: plain NSViewResults (25,000 buttons created and removed; only 10 alive at a time): modefootprint (MB) at 5k / 15k / 25kNSKeyValueDependencyNSMallocBlockbutton (NSButton in NSStackView)26 / 43 / 60 (steady growth)292,621251,145view (plain NSView)flat at 13172n/aheap shows only 10 live NSButton instances, so the buttons themselves are freed. leaks reports no leaks, so AppKit still holds references to the objects. That is about 12 objects (~3 KB) per button. Allocation stack (MallocStackLogging=1 + malloc_history -callTree NSKeyValueDependency, taken on my real app): -[NSStackView insertArrangedSubview:atIndex:] -[NSView addSubview:] -[NSView _setSuperview:] -[NSView(NSViewRoot) _updateViewRoot] -[NSControl _viewRootDidChange] -[NSControl _setupGestureRecognizers] __cons_NSDP_NSDPTypeBool_block_invoke.273 NSDP_getComputedPropertyValue -[NSKeyValueDependencyInfo addDependencyInContext:onValueForKey:] _objc_rootAllocWithZoneThe allocation happens when an NSControl is added to a view hierarchy that has a window (_viewRootDidChange → _setupGestureRecognizers). The KVO dependency objects are never released after the control is removed and deallocated. Real-world impact: an app rebuilt about 40 buttons every 5 s. That leaked about 40 objects per second (~16 MB/hour). After 19 days it reached 7.2 GB footprint, mostly small malloc blocks, with ~1.4M NSKeyValueDependency objects and ~1.4M blocks. Questions: Is this a known issue? Is there a Feedback number? Is there a supported way to avoid or release these dependency objects, other than not recreating NSControls? Does it reproduce on macOS 26.x or 27 betas? Workaround for now: reuse buttons and only rebuild when state actually changes.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
1
Boosts
0
Views
74
Activity
2w
iOS 27: app is not made inactive while the ATT prompt (or other permission alerts) is shown (FB25446786)
Since iOS 27, showing a system permission alert no longer deactivates the app. On iOS 26, sceneWillResignActive / applicationWillResignActive arrive about 0.05–0.1 s after ATTrackingManager.requestTrackingAuthorization. On iOS 27.0, 27.0.1 and 27.2 they don't arrive at all while the prompt is up, and SwiftUI's scenePhase stays .active. Apps that pause on resign, like games (Unity's iOS player pauses only on applicationWillResignActive), keep running behind the prompt: tutorials start, and timers and audio keep going. Minimal repro (plain UIKit with UIScene, fresh install so the status is .notDetermined): private var askedForTracking = false func sceneDidBecomeActive(_ scene: UIScene) { print("sceneDidBecomeActive") guard !askedForTracking else { return } askedForTracking = true DispatchQueue.main.asyncAfter(deadline: .now() + 3) { print("requesting ATT") ATTrackingManager.requestTrackingAuthorization { status in print("ATT finished: \(status.rawValue)") } } } func sceneWillResignActive(_ scene: UIScene) { print("sceneWillResignActive") }iOS 26.6: 3.27s requesting ATT 3.35s willResignActive 16.81s ATT finished: authorized 17.24s didBecomeActiveiOS 27.2: 3.21s requesting ATT 16.88s ATT finished: authorized 17.32s willResignActive 17.33s didBecomeActiveSo on iOS 27 the only lifecycle events are a resign/active pair about 0.44 s after the answer. What we found: The camera and notification permission alerts behave the same. It doesn't depend on the SDK the app is linked against, or on the thread making the request. SpringBoard's log shows the systemModalAlert deactivation assertion being added, but on iOS 27 the updateAllScenesForBand - Assertion added update never reaches the app's scene. The pending reason is only applied on the next unrelated scene update, such as a notification banner arriving, the screen dimming, an unlock, or the alert being dismissed. Taps outside the alert, a Control Center swipe or a home-indicator drag don't trigger it. Filed as FB25446786, with a sample project, delay sweeps on iOS 26 vs 27 (simulator and device) and a sysdiagnose. Is anyone else seeing this? And is there a supported way to know a permission alert is on screen until it's fixed? If you're affected, please file a Feedback and mention FB25446786; duplicates help.
Replies
0
Boosts
0
Views
81
Activity
2w
Issue: Screen rotation becomes locked when updating the status bar on an iPhone Duo.
Issue: Screen rotation becomes locked when updating the status bar on an iPhone Duo. This does not appear to be a device-specific hardware issue; however, it occurs specifically on the iPhone Duo. In my app, if I change the status bar visibility (using prefersStatusBarHidden) while on the iPhone Duo’s external screen, and then immediately unfold the device to reveal the internal screen, the app’s rotation state becomes locked. Although I use prefersInterfaceOrientationLocked to manage rotation, the app remains locked even when this property returns false. The issue persists even when prefersInterfaceOrientationLocked is commented out or removed entirely. Returning to the device’s home screen, rotating the device, and then re-entering the app resolves the lock. Has anyone encountered or resolved a similar issue?
Replies
0
Boosts
0
Views
83
Activity
2w
How to get UIInputView to appear with same height as standard keyboard?
I'm creating a custom keyboard by subclassing UIInputView. This is set as a text field's inputView property. This is a simple keypad similar to the standard numeric keypad keyboard. In fact, my UI lets the user switch between the standard numeric keypad and my custom input view. Given this it would be very nice if my custom input view was the same height as the standard keypad. If there a proper way to subclass UIInputView such that its height is the same "standard" height as the numeric keypad when run on any iOS device from iOS 17 through 27.3? I do not want to have to hardcode dozens of heights for every model iPhone and iPad, not to mention the 5 different heights you get on the iPhone Duo. I've tried various combinations of setting allowsSelfSizing to true and false along with returning a height of UIView.noIntrinsicMetric in intrinsicContentSize as well as not setting intrinsicContentSize at all. The closest result is when allowsSelfSizing is set to false. In that case my custom input view's height is somewhat similar to the standard keypad but in some cases it's off by 20-30 points roughly. Has anyone implemented a custom UIInputView that gets the standard keyboard height without hardcoding device specific heights?
Replies
0
Boosts
1
Views
113
Activity
2w
CarPlay Video entitlement causes blank screen and no CPTemplateApplicationScene callbacks
I have CarPlay Video enabled for my account and App ID. I tested both my main app and a completely new minimal iOS app with a new Bundle ID. The minimal app only contains: UIApplicationDelegate CPTemplateApplicationScene configuration CPTemplateApplicationSceneDelegate A single CPListTemplate root Results: With com.apple.developer.carplay-audio only, CarPlay launches normally. When com.apple.developer.carplay-video is added, CarPlay opens a blank screen. No CarPlay callbacks are called: application(:configurationForConnecting:options:) CPTemplateApplicationSceneDelegate.templateApplicationScene(:didConnect:) CPApplicationDelegate.didConnectCarInterfaceController The signed app and embedded provisioning profile both contain com.apple.developer.carplay-video. Does CarPlay Video require an additional runtime allowlist, specific head unit support, a different scene configuration, or another entitlement beyond com.apple.developer.carplay-video?
Replies
5
Boosts
1
Views
1.1k
Activity
2w
UINavigationController, Nav Bar does not extend to top on iPhone Duo
When using a background color for a UINavigation controller it seems the header does not extend to the top of the device for iPhone Duo when its closed in portrait mode. See screenshot. It should fill the entire 'status' bar up to top of device, Landscape correctly works, its just Portrait. Any thoughts on if this is 'expected' behavior? Seems odd to not just extend the navbar alll the way to the top.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
6
Boosts
2
Views
978
Activity
2w
iOS 26: FloatingBarContainerView overlapping the whole custom ViewController
Hi everyone: I'm experiencing an issue in iOS 26. I've implemented a custom ViewController. It's super simple to edit images with flip, crop, zoom in, and zoom out. My question is that it seems very strange to me. It works without problems in iOS 17.5 and iOS 18. However, when I try to run it with iOS 26, the entire ViewController seems disabled; it doesn't recognize touches or anything. When I checked the UI hierarchy, I saw a strange FloatingBarContainerView overlaying the entire ViewController. I searched the documentation for information about this view, but I couldn't find anything. Any help on how to hide or remove this view in iOS 26? This hasn't been implemented anywhere.
Replies
3
Boosts
0
Views
1.1k
Activity
2w
Finger input interrupted while drawing with Apple Pencil + palm resting on display
I’m investigating an issue with simultaneous Apple Pencil and finger input on iPad. Apple Pencil + finger input works correctly while the Pencil user’s hand/palm is off the display. However, when drawing naturally with Apple Pencil with the palm resting on the display, an existing finger drawing contact elsewhere on the screen can be cancelled and then stop receiving input for several seconds. Pencil input continues normally throughout. Initially I suspected PencilKit, but I’ve reproduced the underlying behaviour below PencilKit/SwiftUI. Instrumenting UIKit at UIApplication.sendEvent shows the finger touch being cancelled and, in some cases, no further events for that finger for ~4–5 seconds while Pencil MOVED events continue to arrive normally. Everything delivered to the application is accounted for, so this appears to occur before our drawing/rendering code. Is this expected behaviour from the iPad’s Pencil/palm rejection? More specifically: Is there any supported way to tell UIKit that an existing finger contact should remain intentional while Pencil + palm contact is present? Is palm rejection configurable at this level? Is there another public input API we should be using for this scenario? We’re currently testing UIEvent.coalescedTouches(for:) to determine whether additional genuine finger samples are available during these apparent gaps, but haven’t completed that test yet. Any guidance on whether this interaction is expected to be supportable through public UIKit APIs would be appreciated.
Replies
3
Boosts
0
Views
1.1k
Activity
2w
Keyboard Toolbar Padding iOS26
When I create a SwiftUI toolbar item with placement of .keyboard on iOS 26, the item appears directly on top of and in contact with the keyboard. This does not look good visually nor does it match the behavior seen in Apple's apps, such as Reminders. Adding padding to the contents of the toolbar item only expands the size of the item but does not separate the capsule background of the item from the keyboard. How can I add vertical padding or spacing to separate the toolbar item capsule from the keyboard?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
15
Boosts
9
Views
2.4k
Activity
2w
iPhone Duo - Buggy margin shift while dragging down a modal view controller
Has anyone else run into this issue? If you present a view controller and set its isModalInPresentation property to true, then when you try to drag down the view controller (which can't be dismissed), the view controller's content on the side of the vertical toolbar is shifted inward. This happens on a closed iPhone Duo. Even the title shifts if the vertical toolbar is on the left side. To replicate, create a Swift/UIKit project. Edit the main storyboard by deleting the default view controller scene and add a navigation controller (and its default root view controller). Set the class for the root view controller to ViewController. Then replace the default ViewController.swift code with the following: import UIKit class ViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() let modal = UIBarButtonItem(systemItem: .add, primaryAction: .init(handler: { _ in let vc = ViewController() vc.title = "Some Modal" // If the following is true, dragging the modal view controller // down results in the table margins being shifted on whichever // side has a vertical toolbar. This happens on the iPhone Duo // when closed in either portrait or landscape. Whichever side // has the vertical toolbar gets shifted. // When the iPhone Duo is open the modal appears in a form sheet // and it does not demonstrate the issue. // The navigation title is also affected when the iPhone Duo is // closed and in landscape with the vertical toolbar on the left. // If the following is false, dismissing the modal by dragging it // down does NOT result in any change in the table's margins. vc.isModalInPresentation = true // false let nc = UINavigationController(rootViewController: vc) self.present(nc, animated: true) })) navigationItem.rightBarButtonItem = modal } } extension ViewController { override func numberOfSections(in tableView: UITableView) -> Int { 2 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 4 } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // Some simple table cells to demonstrate the margin shift let cell = tableView.dequeueReusableCell(withIdentifier: "cell") ?? UITableViewCell(style: .value1, reuseIdentifier: "cell") cell.textLabel?.text = "Some Text" cell.detailTextLabel?.text = "Value" cell.accessoryType = .disclosureIndicator return cell } } Build and run the app with Xcode 27.1 and run it on an iPhone Duo (simulated or real). Tap the + icon to display the modal view controller (just another instance of ViewController). Now try to drag down the modal view controller. Notice the margin shift if the Duo is closed. There is no margin shift is the Duo is open or if isModalInPresentation is set to false. This has been reported as FB25221160.
Replies
2
Boosts
0
Views
776
Activity
2w
Standard toolbar hidden below tab bar in iOS 27.x when running on iPhones
There have been report several issues with this configuration in very old iOS versions. From iOS 27 it seems to be a problem again, or? Assume you have a tab bar controller that contains one ore move navigation controllers. These navigation controllers have one view controller that adds buttons to the navigaton controller's toolbar. Running the app on an iPad, everything works well. Running it on an iPhone, the toolbar is hidden below the tab bar. Is there any workaround to fix this? PS: A simple scene file is attached that shows the issue.
Topic: UI Frameworks SubTopic: UIKit
Replies
0
Boosts
0
Views
50
Activity
2w
iOS 27: SwiftUI TextField text invisible while typing when the app runs in Arabic (FB25410049)
Since iOS 27, if an app runs in Arabic (or, presumably, any right-to-left language), typing digits or Latin letters into a SwiftUI TextField makes the field look empty. The binding updates and the caret shows, but the text isn't drawn until editing ends. What I measured: The text's layout fragment is placed at about x = −39,655 pt in a 370 pt wide field, so it's drawn far outside the field. A plain TextField and one with .environment(\.layoutDirection, .leftToRight) (phone and card numbers) are both affected. A UIKit UITextField on the same screen isn't affected. The same build on iOS 18.0 works, and iOS 27 in English works. Minimal repro: one SwiftUI file with four fields. Run it with App Language set to Arabic, tap the first field and type 523. Launch with -autoProbe to have it type into each field and print where the text was laid out. PROBE iOS 27.0, language ar, layout RTL PROBE field 1 text="523" fieldWidth=370 fragmentX=[-39655] visible=false // SwiftUI TextField PROBE field 2 text="523" fieldWidth=370 fragmentX=[-39655] visible=false // SwiftUI, LTR pinned PROBE field 3 text="523" fieldWidth=370 fragmentX=[314] visible=true // UIKit UITextFieldWorkaround that works for us, installed once at launch: import UIKit enum TextFieldDirection { static func install() { for name in [UITextField.textDidBeginEditingNotification, UITextField.textDidChangeNotification] { NotificationCenter.default.addObserver(forName: name, object: nil, queue: .main) { note in guard let field = note.object as? UITextField else { return } MainActor.assumeIsolated { settle(field) } // SwiftUI rebuilds the paragraph style right after; settle again. DispatchQueue.main.async { MainActor.assumeIsolated { settle(field) } } } } } @MainActor static func settle(_ field: UITextField) { let direction: NSWritingDirection = field.effectiveUserInterfaceLayoutDirection == .rightToLeft ? .rightToLeft : .leftToRight if let whole = field.textRange(from: field.beginningOfDocument, to: field.endOfDocument) { field.setBaseWritingDirection(direction, for: whole) } func directed(_ attributes: [NSAttributedString.Key: Any]) -> [NSAttributedString.Key: Any] { var attributes = attributes let style = (attributes[.paragraphStyle] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle ?? NSMutableParagraphStyle() style.baseWritingDirection = direction attributes[.paragraphStyle] = style return attributes } if let typing = field.typingAttributes { field.typingAttributes = directed(typing) } field.defaultTextAttributes = directed(field.defaultTextAttributes) field.setNeedsLayout() field.layoutIfNeeded() } }Don't pin textAlignment instead. SwiftUI puts .natural back on every keystroke and the caret jumps from side to side. If you see this too, please file a duplicate referencing FB25410049. Duplicates help Apple prioritise it.
Replies
1
Boosts
0
Views
119
Activity
2w
How do deal with NavigationSplitView not saving selection on iPhone
I have a detail view that has a @Binding var Thing, which is passed to it from the parent. It has TextFields that need to use that bound object's fields. // Using this to pass the selection around @Observable class AppSelection { var selectedThings:Set<Thing> = Set(); } struct ContentView: View { @State private var selectionStore = AppSelection(); var body: some View { NavigationSplitView { ... } content: { ...list that sets the selectionStore.selectedThings... } detail: { if !selectionStore.selectedThings.isEmpty { DetailView(thing:Binding( get: { selectionStore.selectedThings.first! }, // Crashes here set: { selectionStore.selectedThings = [$0] } )) .frame(maxHeight:.infinity, alignment:.top) } else { Text("Select a thing."); } } } } struct DetailView:View { @Binding var thing:Thing; var body:some View { TextField("Blah", $thing.name); TextField("Blerg", $thing.stuff); } }A crash happens when I navigate back from the DetailView in the line commented as such. I assume the NavigationSplitView is resetting the selection back to an empty state. Why the Binding given to the DetailView is even trying to get its value at that point is beyond me (so much weirdness in SwiftUI). I've taken so many different stabs at trying to make things work differently, but I just don't understand enough about SwiftUI. Like can I make the DetailView take an optional binding? If the Thing is nil, then all the TextFields complain that they require a non-optional binding. I don't even want to show the Detail view if nothing is selected (hence the "Select a thing.").
Replies
1
Boosts
0
Views
887
Activity
2w
iPhone Duo: Sidebar toolbar item becomes unreachable after rotating to portrait
On the unfolded iPhone Duo simulator, I can reach Settings through the toolbar overflow in landscape. After I rotate to portrait and open the floating sidebar, Settings disappears from both the toolbar and the available menus. I’ve seen this on iOS 27.1 and 27.2. I also reproduced it in a standalone UIKit app on iOS 27.2 and attached the Xcode project to Feedback Assistant report FB25402191. The standalone sample uses a two-column UISplitViewController with a UINavigationController in each column. The primary view controller assigns five actions to toolbarItems once in viewDidLoad, with Settings last. All five use the default visibility priority. The app makes no changes to its toolbar items during rotation. Steps to reproduce Fully unfold the simulated device and rotate to landscape with the detail pane’s vertical toolbar on the right. Widen the sidebar until all five buttons, including the Settings gear, appear in its bottom toolbar. Narrow the sidebar to about 280 points. Four buttons remain along the bottom. Open the ellipsis menu in the detail pane and tap Settings to confirm the action works. Keeping the device unfolded, rotate 90 degrees left into portrait. Tap the sidebar button to reveal the floating sidebar. I expected Settings to remain reachable through an overflow menu if the gear couldn’t fit. Instead, the floating sidebar shows four buttons, and neither pane offers an overflow menu containing Settings. The Settings item is still present in the primary view controller’s toolbarItems array. Rotating back to landscape makes it reachable again. Has anyone reproduced this on a physical iPhone Duo? Is there a supported way to keep an overflowed primary toolbar action accessible when the sidebar changes from a side-by-side column to a floating panel?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
82
Activity
2w
iPhone Duo black bars in landscape on iOS 27.1
I am implementing support for iPhone Duo, and have seen this in many places: Apps built with the iOS 27.1 SDK or later are optimized for iPhone Duo. Apps will extend to use the full display, with toolbars and tab bars appearing vertically below the status bar. (from https://developer.apple.com/iphone-duo/prepare/) But when I build my application in Xcode 27.1, in both the simulator, and on the Duo hardware, my application is not extending to the full-width of the screen when built for iOS 27.1. There are black bars on both the left and right. When I debug the view hierarchy, I do not see the black bars, which indicates to me this is happening at the OS level, not as a result of my constraints. Note that there are no black bars in portrait mode, or on the front screen. In my project settings, only the iPhone Orientation "Portrait" is checked, but I don't want to check Landscape orientations there, because the application does not look good in landscape on a standard iPhone aspect ratio. Are those checkboxes required to remove the black bars? (Checking them does appear to do so, but again, this is quite problematic for the current design of the application.) Thanks in advance for any insights or help you can provide!
Topic: UI Frameworks SubTopic: UIKit
Replies
3
Boosts
0
Views
116
Activity
2w
No access to dictation from third-party keyboards on iPhone Duo
On a physical iPhone Duo running iOS 27.1 and later, the system dictation button is placed inside the system keyboard, next to the space bar. Because the button belongs to the system keyboard layout, it isn't available while a third-party keyboard is active. On other iPhone models, the dictation button appears separately from the keyboard, so it stays available with third-party keyboards. On iPhone Duo, our users have no way to start dictation without switching back to the system keyboard. The iPhone Duo Simulator shows the button at the far right, which doesn't match the physical device, so this can't be evaluated accurately in the Simulator. As far as I can tell, there is no public API that lets a keyboard extension start system dictation, so we can't work around this from the extension. My questions: Is this placement intended on iPhone Duo? Is there a supported way for a keyboard extension to offer dictation on this device? If not, are there plans for a separate system dictation button, as on other iPhone models, or a public API for keyboard extensions? I've filed this as FB[number]. If you develop a keyboard extension and see the same issue, please file your own report and reference this number.
Replies
1
Boosts
0
Views
129
Activity
2w
PDFView context menu: "Actual Size"
In a PDFView, the OS provides a context menu which contains (among other things) "Actual Size" zoom. This command wrongly displays the page at 1 point = 1 pixel. Traditionally on MacOS, "Actual Size" displays the page at 1 inch on page = 1 inch on screen, e.g. for a Letter page, 8.5 x 11 inches on the screen. (So the API needs to determine the display's pixel density to calculate the zoom size.) In Preview 11.0 on Os 27.2, "Actual Size" in the PDFView context menu and in the View menu both zoom to 1 point = 1 pixel. In Preview on Sequoia, Actual Size in the View menu displays at 1 inch = 1 inch, but the context menu gives 1 pt = 1px. (The latter presumably relying on the built-in context menu from PDFView.) Note that in Pages.app, Actual View gives the expected 1 inch = 1 inch on screen.
Replies
1
Boosts
0
Views
110
Activity
2w