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

How to handle all the core AppleEvents
Glancing through the APIs, SwiftUI can handle the open app, reopen app, open doc, and quit core events (with the “aevt” suite ID). What about the print doc and open content events? If there are no hooks (yet), how can I implement them the traditional way without clashing with SwiftUI?
0
0
62
1w
Digital Wallet Verification Options
Good Morning all! I was wondering what the customization is in regard to Digital Wallet Verification. Currently we have Verify with Phone Call as the default option selected, then Verify within App as the second option. Is there a way or any documentation that can be looked at to see how we can have Verify within App be the defaulted option?
0
0
40
1w
iOS 18.6.2 issue with "let"
I am facing an issue in SwiftUI on iOS 18.6.2 where passing a value to a destination view during navigation is not working as expected. In my implementation, I pass a billerId as a constant (let) to the destination view (BillersItemView) using NavigationLink. This approach works correctly across all previous iOS versions. However, on iOS 18.6.2, the destination view does not receive the updated value properly. Before triggering navigation, the value is correctly updated in the ViewModel, but the destination view seems to receive an incorrect or stale value, which affects further API calls and UI rendering. This pattern of passing immutable (let) values is used throughout the app and has always worked reliably, so this behavior appears inconsistent and possibly related to changes in SwiftUI navigation handling in iOS 18.6.2. Could you please confirm if this is a known issue or if there are any recommended changes or workarounds to ensure correct data passing in this scenario? It can be very likely a SwiftUI navigation state timing issue that became more visible in iOS 18.x, especially with NavigationLink(isActive:) + external @ObservedObject updates. But i need to know why this is working in others. I have attached the relevant code for your reference. import SwiftUI struct CategoryBillersView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel @State private var goToBillerItem = false var body: some View { NavigationView { VStack { NavigationLink(isActive: $goToBillerItem) { BillersItemView( billPaymentsVM: billPaymentsVM, billerId: billPaymentsVM.selectedBillerId ) } label: { EmptyView() } Button("Go to Biller") { billPaymentsVM.selectedBillerId = 123 goToBillerItem = true } } } } } struct BillersItemView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel let billerId: Int var body: some View { Text("Biller ID: \(billerId)") .onAppear { billPaymentsVM.fetchBiller(billerId: billerId) } } } class BillPaymentsViewModel: ObservableObject { @Published var selectedBillerId: Int = 0 }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
51
1w
Right Way of Positioning an Always Visible Overlay on Top of Navigation Bar That Aligns With Other Navigation Items
Starting with Liquid Glass, the navigation items seem not to be vertically centered within the navigation bar. This makes it very challenging to position an overlay on top of the navigation bar so that it aligns naturally with other elements such as the back button, dismiss button, and others. We want to achieve this for a progress bar so that it remains visible regardless of which views are pushed underneath. Therefore, we cannot add it as a navigation item on each screen, as doing so would cause the progress bar to animate repeatedly as new screens are pushed onto the stack. This used to be easier pre liquid glass since navigation items were centered vertically within the navigation bar. The approach I tried to center the progress bar in the navigation bar: Get access to the top safe area insets through GeometryReader Get access to the the status bar height through UIWindowScene's statusBarManager Subtract status bar height from top safe area inset to calculate the navigation bar height Update the padding of the progress bar accordingly to make sure it is centered within the navigation bar This works, but as I mentioned, now the navigation items are not centered, and the amount of vertical offset they have seems to differ from one screen to another, making it impossible to come up with an additional padding value to align across devices. See how the navigation item looks like within the navigation bar in the view debugger (doesn't matter if it is UINavigationController or NavigationStack the behaviour is the same, also please note that the positioning is the same for a view without an explicit leading toolbar item, where the default back button is provided by the system when a view is pushed): Existing code (without any hacky solutions) to add a progress bar on top as overlay: struct ContentView: View { @State var shouldShowOverlay = false var body: some View { NavigationStack { NavigationLink("Go to View2") { View2() } .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .topBarLeading) { Button { } label: { Image(systemName: "chevron.left") } } } } .overlay(alignment: .top) { ProgressView(value: 0.5) .frame(width: 200) // what to add as padding here // .padding(.top, 16.0) } } How it looks: Some additional observations for the navigation bar item here: There seems to be 4 _UINavigationBarPlatterAnimationViews in the view stack, prior to the bar button item:
 The first two seems to be fine, they both have (0, 0, 44, 44) for both frame and bounds
 The third one’s frame has height and width of 48.2, and x, y values of -2.1. The last one’s frame has 40,17 for height and width and 1.92 for x,y values. Both views have the following bounds: (0, 0, 44, 44). I also tried to access to the origin of the back bar button item so that I could calculate where the position the overlay, but that also didn't yield to something useful, not to mention it would also be a super hacky solution. So my ultimate question is, is there a clean way to position an overlay on top of the navigation bar that vertically aligns with other navigation bar items, or should we just position it elsewhere and do not mess with navigation bar anymore? Any input would be greatly appreciated.
0
1
147
1w
CarPlay voice-based-conversational app crashes when CarPlay scene activates before phone scene (React Native + Expo)
Hi all, I'm building a CarPlay app for the voice-based-conversational category (entitlement approved March 2026), and I've hit a crash I can't resolve through public documentation. Hoping someone here has seen this. Setup App: React Native via Expo SDK 54 (RN 0.81) CarPlay library: react-native-carplay@2.4.1-beta.0 iOS: 26.4.2 Entitlement: com.apple.developer.carplay-voice-based-conversation Architecture: ExpoAppDelegate subclass with two scene delegates declared in UIApplicationSceneManifest: PhoneSceneDelegate (UIWindowSceneDelegate) CarSceneDelegate (CPTemplateApplicationSceneDelegate) What works iPhone app launched first, CarPlay connects after: no crash. Placeholder CPListTemplate titled "Enough" displays. templateApplicationScene(_:didConnect:) is called. However the React Native side never receives the didConnect event from RNCarPlay — the placeholder is the only thing that ever shows. JS never gets a chance to call setRootTemplate(VoiceControlTemplate). What fails When CarPlay is the first scene to activate (iPhone app not running, user opens the app icon directly on the head unit), the app crashes immediately: Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x0000000190932800 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Triggered by Thread: 0 Thread 0 Crashed: 0 libswiftCore.dylib _assertionFailure(...) AssertCommon.swift:171 1-5 Enough (our Swift code, in CarSceneDelegate path) 6 libdispatch.dylib _dispatch_call_block_and_release Thread 11 (in parallel): hermes evaluatePreparedJavaScript React ReactInstance::loadScript React RCTJSThreadManager runRunLoop So React Native is bootstrapping on Thread 11 (Hermes loading the bundle), but Thread 0 fires a Swift assertion in our code path immediately after factory.startReactNative(...). What we've tried ~16 builds with iterative hypotheses. Two key ones: Passing UIWindow(frame: UIScreen.main.bounds) to factory.startReactNative(in:): crashes because iOS 13+ requires every UIWindow to belong to a UIWindowScene, and we were creating one without scene association. Passing nil to factory.startReactNative(in:): the header RCTReactNativeFactory.h declares inWindow:(UIWindow *_Nullable)window, so nil should be valid. But the crash signature is identical — Swift assertion failure inside ExpoReactNativeFactory or RCTReactNativeFactory. Looks like an internal precondition that requires window != nil despite the header. Other hypotheses ruled out: linker stripping of scene delegate classes (verified with nm), wrong protocol method signature (we use didConnect: for voice-based-conversational, not didConnect:to: which is for navigation apps), AppDelegate vs SceneDelegate bootstrap conflict. One hypothesis we haven't tested: bootstrapping React Native fully in application:didFinishLaunchingWithOptions: before any scene activates, exposing the bridge via singleton. This is the pattern documented in RN issue #41777 and the Adapptor blog (2022). We haven't tried because ExpoReactNativeFactory is more opaque than the older RCTAppDelegate and we're unsure which internal initialization steps are safe to extract. Specific questions Is RCTReactNativeFactory.startReactNative(withModuleName:in:launchOptions:) actually supported with nil window? The _Nullable annotation suggests yes, but runtime says no. Is the annotation aspirational or am I missing a setup step? For React Native apps using voice-based-conversational, is there a recommended pattern to handle CarPlay-first launch? All public documentation I've found is either for legacy CPApplicationDelegate or for navigation apps with MapTemplate. Can VoiceControlTemplate be presented from native Swift without involving the JS bridge for the initial template? This would let us avoid the bridge bootstrap problem on the CarPlay scene path. Any insights, war stories, or pointers to documentation I might have missed would be hugely appreciated. Multi-week investigation here and I'd love to find the right pattern or confirm an upstream issue worth filing as feedback. Thanks!
1
0
125
1w
`safeAreaInsets` but for system bars?
Is there a safeAreaInsets equivalent that only tracks system bars (tab bars, status bars, side bars, toolbars, and navigation bars) and is not affected by notches? I'm asking this because the iPadOS tab bar can appear either on the top, bottom, or left (modally or non-modally) in various configurations, including sidebarAdaptable and when the window size is small on iPadOS; the tab bar's frame is not really reliable in this case, and while the safe area insets works, it also includes the notches / rounded window corners...
0
0
160
1w
MacCatalyst, UIScene and the green zoom/fullscreen button
Please show me where I’ve gone amiss in MacCatalyst and UIScenes with regard to the macOS green zoom/fullscreen button. Originally the MacCatalyst App used a secondary AppKit bundle for its NSWindow work, but at some point in time AppStore Connect complained about this secondary bundle which prevented new App uploads. To continue receiving green button notifications I switched to UINSWindow. That worked. Now that I’m forced to use UIScenes I’m in a pickle: a click on the green button forces an automatic jump to fullscreen, nothing I can do about it AFAIK. A poor, poor compromise would be to disable the green button but I have no idea how even to do that. I’d like my App to exist in two states, any suggestions? Thanks.
1
0
122
1w
How to achieve this vibrant background effect on iOS?
Hi everyone, I'm trying to reproduce an effect that Apple has created for the Contacts app on iOS, iPadOS and MacOS v26.4 where the contact card is displayed with a nice material frosted background that blends well with the underlying background. I love this effect and I want to use it in my app to display different information. As you can see in the screenshot, the list rows have a frosted background (probably thinMaterial) combined with a vibrant effect that adapts to the underlying view background. Additionally, the fields labels and icons also have a nice effect. I've tried everything but I'm unable to accurately recreate this effect. I tried applying a Rectangle with a material background listRowBackground but this resulted in something different than what Apple is using (either too light, too dark, or simply not vibrant). I've even tried SwiftUIVisualEffects swift package which can apply a vibrancy effect. However the result is still not the same as the one you see in the screenshot, with the correct contrast between background and labels. Any guidance would be appreciated. Thank you 🙏🏻
4
0
360
1w
apply .activityBackgroundTint modifier in smartstack
On iOS 26, when using .activityBackgroundTint modifiers to change the background color in the Activity Kit, the changes do not appear to apply correctly in Smart Stack. While the color changes as expected, the background is rendered as simply transparent without a glass effect which reduces readability. The glass effect is applied only when activityBackgroundTint is not used.
0
0
176
1w
tabViewBottomAccessory does not inherit tab bar vibrancy / foregroundStyle behavior
Hi, I’m experimenting with the new tabViewBottomAccessory API and I’m running into an inconsistency with how colors are handled compared to the native tab bar items. Context When using a TabView, the system tab bar automatically adapts its foreground color (icons and labels) based on the background content (light/dark, images, etc.). This is the expected “vibrancy” behavior. However, when adding content via .tabViewBottomAccessory, the foreground color does not seem to follow the same logic. Minimal example : import SwiftUI struct ContentView: View { var body: some View { TabView { Tab("Home", systemImage: "house") { Text("Home") .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() } Tab("New", systemImage: "squareshape.split.2x2") { Text("New") .frame(maxWidth: .infinity, maxHeight: .infinity) .foregroundStyle(.white) .background(Color.black) .ignoresSafeArea() } } .tabViewBottomAccessory { HStack { Image(systemName: "command.square") Text("Message test") Spacer() Image(systemName: "play.fill") } .padding(.horizontal, 20) .foregroundStyle(.primary) } } } Observed behavior Tab bar icons and labels correctly switch between dark and light depending on the background. Content inside .tabViewBottomAccessory remains black, even when .foregroundStyle(.primary) is used. Expected behavior I would expect .tabViewBottomAccessory content to: Either inherit the same vibrancy/foreground adaptation as the tab bar items Or have a documented way to match that behavior I want to reuse the Apple Music Navigation
Topic: UI Frameworks SubTopic: SwiftUI
0
0
77
1w
ExcUserFault and corrupted data when using UIImage#heicData
Over the last two weeks, I’ve had sporadic reports from users who suddenly have a corrupt image in the database for my app. It’s only affecting a few users and may possibly have been fixed with iOS 26.4.1 (I’m not sure). In any case, this started suddenly with the release of iOS 26.4 - our app has not been changed in several months. But I wanted to share what’s happening in case others are experiencing this. My app lets users import photos from the camera roll, photo albums, etc. Once the user has selected an image, the app saves this to a SQLite3 database using “image.heicData()”. For the four or five users who have been affected by this problem, the heicData call returns successfully, with a non-nil Data value. But the image itself is corrupt and unreadable. When the user tries to later open a screen containing the image, the app crashes. I’ve had to manually guide each user through tracking down and removing the affected item or items to resolve it, which is a bad experience for them and time-consuming for us. Our app crashes when it tries to read the image (using “UIImage(data: heicData)”). All users who have this problem have had an ExcUserFault file in their crash reports with our app name in it. It's not possible to symbolicate this file but i've included an excerpt at the bottom of this post: I was able to extract some raw data saved when this error occurs. When you run “file corrupt_image.heic”, you get: AmigaOS bitmap font "rtypheic", fc_YSize 0, 35001 elements which definitely doesn’t seem right. On a valid HEIC file, i get: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile Is anyone else experience this? Or does anyone else have any suggestions about what could be happening? I submitted feedback FB22667639 about this. ExcUserFault example Exception Type: EXC_GUARD Exception Subtype: GUARD_TYPE_USER Exception Message: namespc 7 reason_code 0x0000000000000009 Exception Codes: 0x6000000000000007, 0x0000000000000009 Termination Reason: Namespace LIBXPC, Code 9, XPC_EXIT_REASON_FAULT Thread 0: 0 ??? 0x231fa997c 0x180000000 + 2985990524 1 ??? 0x197eb98b4 0x180000000 + 401316020 2 ??? 0x197ec4e04 0x180000000 + 401362436 3 ??? 0x197ec5ea0 0x180000000 + 401366688 4 ??? 0x19066bdb8 0x180000000 + 275168696 5 ??? 0x19066b968 0x180000000 + 275167592 6 ??? 0x19b5c19a4 0x180000000 + 459020708 7 ??? 0x19b5cfa2c 0x180000000 + 459078188 8 ??? 0x19b5cf838 0x180000000 + 459077688 9 ??? 0x197ec7c74 0x180000000 + 401374324 10 ??? 0x197ec991c 0x180000000 + 401381660 11 ??? 0x1bd74222c 0x180000000 + 1031021100 12 ??? 0x1bd744ba4 0x180000000 + 1031031716 13 ??? 0x1bd730e18 0x180000000 + 1030950424 14 ??? 0x1bd7458f8 0x180000000 + 1031035128 15 ??? 0x1bd730e18 0x180000000 + 1030950424 16 ??? 0x1bd731ae4 0x180000000 + 1030953700 17 ??? 0x1bd73bdac 0x180000000 + 1030995372 18 ??? 0x1bd73b6ac 0x180000000 + 1030993580 19 ??? 0x1e23283b0 0x180000000 + 1647477680 20 ??? 0x1e23278c0 0x180000000 + 1647474880
2
0
256
1w
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label("Overview", systemImage: "archivebox") } Tab(value: .gallery) { GalleryView() } label: { Label("Gallery", systemImage: "shippingbox") } Tab(value: .canvas) { CanvasView() } label: { Label("Canvas", systemImage: "rectangle") } Tab(value: .record) { recordView } label: { Label("Record", systemImage: "plus") } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigation structure may be preventing the animation in other tabs. Each major tab currently owns its own NavigationStack. For example, OverviewView, GalleryView, and CanvasView each have a NavigationStack as their root view. The Record tab conditionally shows different recording views, and one of those views also contains its own NavigationStack. I have already tried several approaches, but none solved the issue reliably: Observing @Environment(.tabBarPlacement) and adding .animation(..., value:) Reporting tabBarPlacement upward using a PreferenceKey and wrapping the update in withAnimation Wrapping tab contents in GeometryReader or other outer layout containers Temporarily removing .tabViewCustomization($tabCustomization) and .customizationID(...) Reducing the implementation to the simplest documented TabView(selection:) + Tab(...) + .tabViewStyle(.sidebarAdaptable) structure Some of these attempts actually made the animation behavior worse, so I reverted them. My questions are: 1.Is the content area expected to animate automatically when TabView(.sidebarAdaptable) changes between sidebar and top bar placement on iPad? 2.Is it recommended for each tab to own its own NavigationStack in this setup? 3.Could tabViewCustomization(:) or customizationID(:) affect the sidebar/top bar transition animation? 4.Is there an official SwiftUI pattern for preserving the system animation transaction during this adaptive tab bar placement change? 5.If this is expected behavior or a current limitation, what structure would Apple recommend for this kind of iPad navigation? Thanks in advance!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
87
1w
ScrollView/ClipView weirdness.
I have been playing around with AppKit programming and I have a sample document based app with a scroll view and rulers. When The scrollbars are not overlay style (which is usually true for me because I have "show scroll bars always" set in preferences) and the rulers are on The clip view seems to extend throughout the scroll view and the document can be seen through the scroll bars. However if I turn the rulers off, then the clip view seems to not include the scroll bars, and so the document is not visible through the scroll bars, having been clipped to the rectangle that lies inside the scroll bars. Additionally in this case, the small area in the lower right hand corner of the screen between the two scroll bars is white, even though all of my views have a light gray background. If the scroll bar style is overlay, then everything seems to work as expected: the clip view always includes the scroll bars. Is this a bug related to legacy style scrollbars or (more likely) have I just screwed something up? I should add that the window and the entire view hierarchy have been built programmatically. It is not in the xib.
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
248
1w
Styling LabeledContent inside a Form on macOS?
On macOS 26, the Label part of a LabeledContent control and the Section.header part of a Section do not seem to honour view modifiers like .controlSize(.small) when used inside a Form with .formStyle(.grouped). Is there a way to make them respect the control size? Example: Form { Section("Details") { LabeledContent("Company", value: "Apple") } } .formStyle(.grouped) .controlSize(.small) // This only effects 'Apple' This produces a view where the value "Apple" is using a smaller font size but the label and the section header are not. I've tried (I think) almost every variation I can think of in terms of creating a LabeledContent and applying .controlSize but all of them come up short. The Form appears to always override my view modifiers for the section heading and label. Example 2: Form { Section { LabeledContent { Text("Company") .controlSize(.small) // Has no effect. } label: { Text("Apple") // Correctly resized to .small. } } header: { Text("Details") .controlSize(.small) // Has no effect. } } .formStyle(.grouped) .controlSize(.small) The best I've been able to come up with is a custom LabeledContentStyle that manually applies the layout and the styling, but that requires I explicitly "recreate" the macOS look-and-feel of left aligned labels and right aligned values by way of an HStack and Spacer. Have I overlooked a way to style a Form or LabeledContent that would provide the results I'm looking for?
0
0
47
1w
How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print("viewDidLayout: \(view.bounds.size)") } override func viewDidAppear() { print("viewDidAppear: \(view.bounds.size)") } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print("onAppear: \(geo.size)") } .onChange(of: geo.size) { print("onChange: \(geo.size)") } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Without rerunning on every layout or geometry change Question What is the proper macOS-native way to perform one-time startup logic only after the final restored window size is available? Is there a recommended lifecycle hook or pattern for this? Also, is it expected behavior that onAppear / viewDidAppear reports the pre-restoration size, or is it a bug?
3
0
192
1w
Crash while running NSAlert.runModal
My application overrides AppDelegate.menuWillOpen(). During startup of the application (in AppDelegate.applicationDidFinishLaunching) I attempt to install a privileged helper tool using SMAppService. On detecting that the tool needs to be allowed/installed I open the Login Items & Extensions settings and then display a modal dialog, advising the user to authorise the privileged helper. Then the application crashes with a message in the crash file Application Specific Information: BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively Maybe I could avoid this by removing the menuWillOpen() override so am looking for a workaround. i.e. is it possible to install the override function programmatically later during initialisation, rather then declaring it in an extension. I have attached the crash log. ChronyControl-2026-04-29-111332.crash
4
0
631
1w
ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
When I set up a toolbar item group with multiple options and set the controlGroupStyle as .palette, and when one of the options are supposed to present a view controller, I get the following error Attempt to present <UINavigationController: 0x101813200> on <ProjectName.HomeTabBarViewController: 0x10701bc00> (from <UINavigationController: 0x107821000>) which is already presenting <_UIContextMenuActionsOnlyViewController: 0x1035c19d0>. So basically the context menu we see is under the hood a view controller that is being presented. Is there a right way of fixing it, or is it maybe something that will be fixed by Apple? This is how I set up the ToolbarItemGroup on SwiftUI and the view model ultimately presents another UINavigationController that has a UIHostingController as its view controller: .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { Button("ft_commons_edit".localised, systemImage: "pencil") { viewModel.didTapEditAction() } Button("ft_commons_delete".localised, systemImage: "trash") { viewModel.didTapDeleteAction() } } label: { Image("edit-icon") .resizable() .frame(width: 24.0, height: 24.0) } } .controlGroupStyle(.palette) This is how the view looks like when presentation fails: As a workaround, I found two options that work well. I’d like to share them and ask for recommendations, just to make sure they won’t cause any unexpected issues later on: Option 1: Access the top most visible view controller and attempt presenting on it This requires the following extension: extension UIViewController { func topMostViewController() -> UIViewController { if let presentedViewController = self.presentedViewController { return presentedViewController.topMostViewController() } else if let navigationController = self as? UINavigationController, let topViewController = navigationController.topViewController { return topViewController.topMostViewController() } else if let tabBarController = self as? UITabBarController, let selectedViewController = tabBarController.selectedViewController { return selectedViewController.topMostViewController() } else { return self } } } Then called as: navigationController.topMostViewController().present(exerciseEditingNavController, animated: true) Option 2: Call dismiss before attempting to present anything This also works fine, even without any delay, the menu is first dismissed and presentation works fine afterwards, code example: navigationController.dismiss(animated: true) navigationController.present(exerciseEditingNavController, animated: true) I feel like Option 1 would be the better choice, because if this context menu is ever no longer treated as a view controller and direct presentation starts working, Option 1 would still behave correctly by presenting from the topmost visible view controller. Option 2, on the other hand, could introduce a bug by dismissing an unrelated view controller if the context menu is no longer represented as a view controller at that point. I would appreciate any advice from anyone who has experienced this, or from Apple developers. Thanks
6
0
328
1w
After binding to NSBrowser indexPaths the browser assumes I'm using NSBrowserCell and calls unimplemented methods on my NSCell subclass
So after binding to NSBrowser selectionIndexPaths: https://developer.apple.com/library/archive/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSBrowser.html this causes NSBrowser to do some weird stuff that seems completely unrelated to this particular binding. It starts calling NSBrowserCell methods on my cells but my cell is not a NSBrowserCell. My cell is actually a subclass of NSTextFieldCell. But NSBrowser starts sending setIsLeaf: (which I don't implement). In any case if I implement the -setLeaf: that solves that unrecognized selector, but now my cells don't draw titles. Not sure why binding to selectionIndexPaths causes this behavior? The cell stuff seems unrelated to this particular binding. I am of course using the newer but still pretty old item based APIs... do these bindings only support using NSMatrix? I do set the binding after calling -setCellClass: but makes no difference. I also just tried overriding -setSelectionIndexPaths: but NSBrowser does not use the setter.
0
0
94
1w
Prominent glass button in SwiftUI incorrect text style
How do you create a prominent glass button in SwiftUI? In UIKit it’s let button = UIButton(configuration: .prominentGlass()) button.configuration?.title = "Agree" I tried Button("Agree") {} .buttonStyle(.glassProminent) but the title text is white not glassified 🤨
Replies
0
Boosts
0
Views
58
Activity
1w
How to handle all the core AppleEvents
Glancing through the APIs, SwiftUI can handle the open app, reopen app, open doc, and quit core events (with the “aevt” suite ID). What about the print doc and open content events? If there are no hooks (yet), how can I implement them the traditional way without clashing with SwiftUI?
Replies
0
Boosts
0
Views
62
Activity
1w
Digital Wallet Verification Options
Good Morning all! I was wondering what the customization is in regard to Digital Wallet Verification. Currently we have Verify with Phone Call as the default option selected, then Verify within App as the second option. Is there a way or any documentation that can be looked at to see how we can have Verify within App be the defaulted option?
Replies
0
Boosts
0
Views
40
Activity
1w
iOS 18.6.2 issue with "let"
I am facing an issue in SwiftUI on iOS 18.6.2 where passing a value to a destination view during navigation is not working as expected. In my implementation, I pass a billerId as a constant (let) to the destination view (BillersItemView) using NavigationLink. This approach works correctly across all previous iOS versions. However, on iOS 18.6.2, the destination view does not receive the updated value properly. Before triggering navigation, the value is correctly updated in the ViewModel, but the destination view seems to receive an incorrect or stale value, which affects further API calls and UI rendering. This pattern of passing immutable (let) values is used throughout the app and has always worked reliably, so this behavior appears inconsistent and possibly related to changes in SwiftUI navigation handling in iOS 18.6.2. Could you please confirm if this is a known issue or if there are any recommended changes or workarounds to ensure correct data passing in this scenario? It can be very likely a SwiftUI navigation state timing issue that became more visible in iOS 18.x, especially with NavigationLink(isActive:) + external @ObservedObject updates. But i need to know why this is working in others. I have attached the relevant code for your reference. import SwiftUI struct CategoryBillersView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel @State private var goToBillerItem = false var body: some View { NavigationView { VStack { NavigationLink(isActive: $goToBillerItem) { BillersItemView( billPaymentsVM: billPaymentsVM, billerId: billPaymentsVM.selectedBillerId ) } label: { EmptyView() } Button("Go to Biller") { billPaymentsVM.selectedBillerId = 123 goToBillerItem = true } } } } } struct BillersItemView: View { @ObservedObject var billPaymentsVM: BillPaymentsViewModel let billerId: Int var body: some View { Text("Biller ID: \(billerId)") .onAppear { billPaymentsVM.fetchBiller(billerId: billerId) } } } class BillPaymentsViewModel: ObservableObject { @Published var selectedBillerId: Int = 0 }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
51
Activity
1w
Remove MacOS Tahoe Sidebar + Inspector Chrome
Is it possible to remove the ugly sidebar and inspector chrome with AppKit? I don't care if it's a hack or a swizzle or something, but I need to get rid of this. I want to convert this: Into this (photoshopped): Thanks for your help!
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
0
Boosts
0
Views
113
Activity
1w
Right Way of Positioning an Always Visible Overlay on Top of Navigation Bar That Aligns With Other Navigation Items
Starting with Liquid Glass, the navigation items seem not to be vertically centered within the navigation bar. This makes it very challenging to position an overlay on top of the navigation bar so that it aligns naturally with other elements such as the back button, dismiss button, and others. We want to achieve this for a progress bar so that it remains visible regardless of which views are pushed underneath. Therefore, we cannot add it as a navigation item on each screen, as doing so would cause the progress bar to animate repeatedly as new screens are pushed onto the stack. This used to be easier pre liquid glass since navigation items were centered vertically within the navigation bar. The approach I tried to center the progress bar in the navigation bar: Get access to the top safe area insets through GeometryReader Get access to the the status bar height through UIWindowScene's statusBarManager Subtract status bar height from top safe area inset to calculate the navigation bar height Update the padding of the progress bar accordingly to make sure it is centered within the navigation bar This works, but as I mentioned, now the navigation items are not centered, and the amount of vertical offset they have seems to differ from one screen to another, making it impossible to come up with an additional padding value to align across devices. See how the navigation item looks like within the navigation bar in the view debugger (doesn't matter if it is UINavigationController or NavigationStack the behaviour is the same, also please note that the positioning is the same for a view without an explicit leading toolbar item, where the default back button is provided by the system when a view is pushed): Existing code (without any hacky solutions) to add a progress bar on top as overlay: struct ContentView: View { @State var shouldShowOverlay = false var body: some View { NavigationStack { NavigationLink("Go to View2") { View2() } .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .topBarLeading) { Button { } label: { Image(systemName: "chevron.left") } } } } .overlay(alignment: .top) { ProgressView(value: 0.5) .frame(width: 200) // what to add as padding here // .padding(.top, 16.0) } } How it looks: Some additional observations for the navigation bar item here: There seems to be 4 _UINavigationBarPlatterAnimationViews in the view stack, prior to the bar button item:
 The first two seems to be fine, they both have (0, 0, 44, 44) for both frame and bounds
 The third one’s frame has height and width of 48.2, and x, y values of -2.1. The last one’s frame has 40,17 for height and width and 1.92 for x,y values. Both views have the following bounds: (0, 0, 44, 44). I also tried to access to the origin of the back bar button item so that I could calculate where the position the overlay, but that also didn't yield to something useful, not to mention it would also be a super hacky solution. So my ultimate question is, is there a clean way to position an overlay on top of the navigation bar that vertically aligns with other navigation bar items, or should we just position it elsewhere and do not mess with navigation bar anymore? Any input would be greatly appreciated.
Replies
0
Boosts
1
Views
147
Activity
1w
CarPlay voice-based-conversational app crashes when CarPlay scene activates before phone scene (React Native + Expo)
Hi all, I'm building a CarPlay app for the voice-based-conversational category (entitlement approved March 2026), and I've hit a crash I can't resolve through public documentation. Hoping someone here has seen this. Setup App: React Native via Expo SDK 54 (RN 0.81) CarPlay library: react-native-carplay@2.4.1-beta.0 iOS: 26.4.2 Entitlement: com.apple.developer.carplay-voice-based-conversation Architecture: ExpoAppDelegate subclass with two scene delegates declared in UIApplicationSceneManifest: PhoneSceneDelegate (UIWindowSceneDelegate) CarSceneDelegate (CPTemplateApplicationSceneDelegate) What works iPhone app launched first, CarPlay connects after: no crash. Placeholder CPListTemplate titled "Enough" displays. templateApplicationScene(_:didConnect:) is called. However the React Native side never receives the didConnect event from RNCarPlay — the placeholder is the only thing that ever shows. JS never gets a chance to call setRootTemplate(VoiceControlTemplate). What fails When CarPlay is the first scene to activate (iPhone app not running, user opens the app icon directly on the head unit), the app crashes immediately: Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x0000000190932800 Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Triggered by Thread: 0 Thread 0 Crashed: 0 libswiftCore.dylib _assertionFailure(...) AssertCommon.swift:171 1-5 Enough (our Swift code, in CarSceneDelegate path) 6 libdispatch.dylib _dispatch_call_block_and_release Thread 11 (in parallel): hermes evaluatePreparedJavaScript React ReactInstance::loadScript React RCTJSThreadManager runRunLoop So React Native is bootstrapping on Thread 11 (Hermes loading the bundle), but Thread 0 fires a Swift assertion in our code path immediately after factory.startReactNative(...). What we've tried ~16 builds with iterative hypotheses. Two key ones: Passing UIWindow(frame: UIScreen.main.bounds) to factory.startReactNative(in:): crashes because iOS 13+ requires every UIWindow to belong to a UIWindowScene, and we were creating one without scene association. Passing nil to factory.startReactNative(in:): the header RCTReactNativeFactory.h declares inWindow:(UIWindow *_Nullable)window, so nil should be valid. But the crash signature is identical — Swift assertion failure inside ExpoReactNativeFactory or RCTReactNativeFactory. Looks like an internal precondition that requires window != nil despite the header. Other hypotheses ruled out: linker stripping of scene delegate classes (verified with nm), wrong protocol method signature (we use didConnect: for voice-based-conversational, not didConnect:to: which is for navigation apps), AppDelegate vs SceneDelegate bootstrap conflict. One hypothesis we haven't tested: bootstrapping React Native fully in application:didFinishLaunchingWithOptions: before any scene activates, exposing the bridge via singleton. This is the pattern documented in RN issue #41777 and the Adapptor blog (2022). We haven't tried because ExpoReactNativeFactory is more opaque than the older RCTAppDelegate and we're unsure which internal initialization steps are safe to extract. Specific questions Is RCTReactNativeFactory.startReactNative(withModuleName:in:launchOptions:) actually supported with nil window? The _Nullable annotation suggests yes, but runtime says no. Is the annotation aspirational or am I missing a setup step? For React Native apps using voice-based-conversational, is there a recommended pattern to handle CarPlay-first launch? All public documentation I've found is either for legacy CPApplicationDelegate or for navigation apps with MapTemplate. Can VoiceControlTemplate be presented from native Swift without involving the JS bridge for the initial template? This would let us avoid the bridge bootstrap problem on the CarPlay scene path. Any insights, war stories, or pointers to documentation I might have missed would be hugely appreciated. Multi-week investigation here and I'd love to find the right pattern or confirm an upstream issue worth filing as feedback. Thanks!
Replies
1
Boosts
0
Views
125
Activity
1w
`safeAreaInsets` but for system bars?
Is there a safeAreaInsets equivalent that only tracks system bars (tab bars, status bars, side bars, toolbars, and navigation bars) and is not affected by notches? I'm asking this because the iPadOS tab bar can appear either on the top, bottom, or left (modally or non-modally) in various configurations, including sidebarAdaptable and when the window size is small on iPadOS; the tab bar's frame is not really reliable in this case, and while the safe area insets works, it also includes the notches / rounded window corners...
Replies
0
Boosts
0
Views
160
Activity
1w
MacCatalyst, UIScene and the green zoom/fullscreen button
Please show me where I’ve gone amiss in MacCatalyst and UIScenes with regard to the macOS green zoom/fullscreen button. Originally the MacCatalyst App used a secondary AppKit bundle for its NSWindow work, but at some point in time AppStore Connect complained about this secondary bundle which prevented new App uploads. To continue receiving green button notifications I switched to UINSWindow. That worked. Now that I’m forced to use UIScenes I’m in a pickle: a click on the green button forces an automatic jump to fullscreen, nothing I can do about it AFAIK. A poor, poor compromise would be to disable the green button but I have no idea how even to do that. I’d like my App to exist in two states, any suggestions? Thanks.
Replies
1
Boosts
0
Views
122
Activity
1w
How to achieve this vibrant background effect on iOS?
Hi everyone, I'm trying to reproduce an effect that Apple has created for the Contacts app on iOS, iPadOS and MacOS v26.4 where the contact card is displayed with a nice material frosted background that blends well with the underlying background. I love this effect and I want to use it in my app to display different information. As you can see in the screenshot, the list rows have a frosted background (probably thinMaterial) combined with a vibrant effect that adapts to the underlying view background. Additionally, the fields labels and icons also have a nice effect. I've tried everything but I'm unable to accurately recreate this effect. I tried applying a Rectangle with a material background listRowBackground but this resulted in something different than what Apple is using (either too light, too dark, or simply not vibrant). I've even tried SwiftUIVisualEffects swift package which can apply a vibrancy effect. However the result is still not the same as the one you see in the screenshot, with the correct contrast between background and labels. Any guidance would be appreciated. Thank you 🙏🏻
Replies
4
Boosts
0
Views
360
Activity
1w
apply .activityBackgroundTint modifier in smartstack
On iOS 26, when using .activityBackgroundTint modifiers to change the background color in the Activity Kit, the changes do not appear to apply correctly in Smart Stack. While the color changes as expected, the background is rendered as simply transparent without a glass effect which reduces readability. The glass effect is applied only when activityBackgroundTint is not used.
Replies
0
Boosts
0
Views
176
Activity
1w
tabViewBottomAccessory does not inherit tab bar vibrancy / foregroundStyle behavior
Hi, I’m experimenting with the new tabViewBottomAccessory API and I’m running into an inconsistency with how colors are handled compared to the native tab bar items. Context When using a TabView, the system tab bar automatically adapts its foreground color (icons and labels) based on the background content (light/dark, images, etc.). This is the expected “vibrancy” behavior. However, when adding content via .tabViewBottomAccessory, the foreground color does not seem to follow the same logic. Minimal example : import SwiftUI struct ContentView: View { var body: some View { TabView { Tab("Home", systemImage: "house") { Text("Home") .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() } Tab("New", systemImage: "squareshape.split.2x2") { Text("New") .frame(maxWidth: .infinity, maxHeight: .infinity) .foregroundStyle(.white) .background(Color.black) .ignoresSafeArea() } } .tabViewBottomAccessory { HStack { Image(systemName: "command.square") Text("Message test") Spacer() Image(systemName: "play.fill") } .padding(.horizontal, 20) .foregroundStyle(.primary) } } } Observed behavior Tab bar icons and labels correctly switch between dark and light depending on the background. Content inside .tabViewBottomAccessory remains black, even when .foregroundStyle(.primary) is used. Expected behavior I would expect .tabViewBottomAccessory content to: Either inherit the same vibrancy/foreground adaptation as the tab bar items Or have a documented way to match that behavior I want to reuse the Apple Music Navigation
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
77
Activity
1w
ExcUserFault and corrupted data when using UIImage#heicData
Over the last two weeks, I’ve had sporadic reports from users who suddenly have a corrupt image in the database for my app. It’s only affecting a few users and may possibly have been fixed with iOS 26.4.1 (I’m not sure). In any case, this started suddenly with the release of iOS 26.4 - our app has not been changed in several months. But I wanted to share what’s happening in case others are experiencing this. My app lets users import photos from the camera roll, photo albums, etc. Once the user has selected an image, the app saves this to a SQLite3 database using “image.heicData()”. For the four or five users who have been affected by this problem, the heicData call returns successfully, with a non-nil Data value. But the image itself is corrupt and unreadable. When the user tries to later open a screen containing the image, the app crashes. I’ve had to manually guide each user through tracking down and removing the affected item or items to resolve it, which is a bad experience for them and time-consuming for us. Our app crashes when it tries to read the image (using “UIImage(data: heicData)”). All users who have this problem have had an ExcUserFault file in their crash reports with our app name in it. It's not possible to symbolicate this file but i've included an excerpt at the bottom of this post: I was able to extract some raw data saved when this error occurs. When you run “file corrupt_image.heic”, you get: AmigaOS bitmap font "rtypheic", fc_YSize 0, 35001 elements which definitely doesn’t seem right. On a valid HEIC file, i get: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile Is anyone else experience this? Or does anyone else have any suggestions about what could be happening? I submitted feedback FB22667639 about this. ExcUserFault example Exception Type: EXC_GUARD Exception Subtype: GUARD_TYPE_USER Exception Message: namespc 7 reason_code 0x0000000000000009 Exception Codes: 0x6000000000000007, 0x0000000000000009 Termination Reason: Namespace LIBXPC, Code 9, XPC_EXIT_REASON_FAULT Thread 0: 0 ??? 0x231fa997c 0x180000000 + 2985990524 1 ??? 0x197eb98b4 0x180000000 + 401316020 2 ??? 0x197ec4e04 0x180000000 + 401362436 3 ??? 0x197ec5ea0 0x180000000 + 401366688 4 ??? 0x19066bdb8 0x180000000 + 275168696 5 ??? 0x19066b968 0x180000000 + 275167592 6 ??? 0x19b5c19a4 0x180000000 + 459020708 7 ??? 0x19b5cfa2c 0x180000000 + 459078188 8 ??? 0x19b5cf838 0x180000000 + 459077688 9 ??? 0x197ec7c74 0x180000000 + 401374324 10 ??? 0x197ec991c 0x180000000 + 401381660 11 ??? 0x1bd74222c 0x180000000 + 1031021100 12 ??? 0x1bd744ba4 0x180000000 + 1031031716 13 ??? 0x1bd730e18 0x180000000 + 1030950424 14 ??? 0x1bd7458f8 0x180000000 + 1031035128 15 ??? 0x1bd730e18 0x180000000 + 1030950424 16 ??? 0x1bd731ae4 0x180000000 + 1030953700 17 ??? 0x1bd73bdac 0x180000000 + 1030995372 18 ??? 0x1bd73b6ac 0x180000000 + 1030993580 19 ??? 0x1e23283b0 0x180000000 + 1647477680 20 ??? 0x1e23278c0 0x180000000 + 1647474880
Replies
2
Boosts
0
Views
256
Activity
1w
SwiftUI TabView(.sidebarAdaptable) does not reliably animate content resize when switching between sidebar and top tab bar on iPad
Hi everyone, I’m building an iPad app in SwiftUI using the adaptive tab navigation pattern: Tab(value: .overview) { OverviewView() } label: { Label("Overview", systemImage: "archivebox") } Tab(value: .gallery) { GalleryView() } label: { Label("Gallery", systemImage: "shippingbox") } Tab(value: .canvas) { CanvasView() } label: { Label("Canvas", systemImage: "rectangle") } Tab(value: .record) { recordView } label: { Label("Record", systemImage: "plus") } } .tabViewStyle(.sidebarAdaptable) .tabViewCustomization($tabCustomization) The issue is that when the adaptive tab bar switches between the sidebar placement and the top bar placement on iPad, the content area resize animation is unreliable. The system navigation chrome changes correctly, but some tab contents jump directly to their final width instead of smoothly animating with the sidebar/top bar transition. Interestingly, one of my record views appears to animate consistently, so it seems the system transition itself is possible, but some view hierarchy or navigation structure may be preventing the animation in other tabs. Each major tab currently owns its own NavigationStack. For example, OverviewView, GalleryView, and CanvasView each have a NavigationStack as their root view. The Record tab conditionally shows different recording views, and one of those views also contains its own NavigationStack. I have already tried several approaches, but none solved the issue reliably: Observing @Environment(.tabBarPlacement) and adding .animation(..., value:) Reporting tabBarPlacement upward using a PreferenceKey and wrapping the update in withAnimation Wrapping tab contents in GeometryReader or other outer layout containers Temporarily removing .tabViewCustomization($tabCustomization) and .customizationID(...) Reducing the implementation to the simplest documented TabView(selection:) + Tab(...) + .tabViewStyle(.sidebarAdaptable) structure Some of these attempts actually made the animation behavior worse, so I reverted them. My questions are: 1.Is the content area expected to animate automatically when TabView(.sidebarAdaptable) changes between sidebar and top bar placement on iPad? 2.Is it recommended for each tab to own its own NavigationStack in this setup? 3.Could tabViewCustomization(:) or customizationID(:) affect the sidebar/top bar transition animation? 4.Is there an official SwiftUI pattern for preserving the system animation transaction during this adaptive tab bar placement change? 5.If this is expected behavior or a current limitation, what structure would Apple recommend for this kind of iPad navigation? Thanks in advance!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
87
Activity
1w
ScrollView/ClipView weirdness.
I have been playing around with AppKit programming and I have a sample document based app with a scroll view and rulers. When The scrollbars are not overlay style (which is usually true for me because I have "show scroll bars always" set in preferences) and the rulers are on The clip view seems to extend throughout the scroll view and the document can be seen through the scroll bars. However if I turn the rulers off, then the clip view seems to not include the scroll bars, and so the document is not visible through the scroll bars, having been clipped to the rectangle that lies inside the scroll bars. Additionally in this case, the small area in the lower right hand corner of the screen between the two scroll bars is white, even though all of my views have a light gray background. If the scroll bar style is overlay, then everything seems to work as expected: the clip view always includes the scroll bars. Is this a bug related to legacy style scrollbars or (more likely) have I just screwed something up? I should add that the window and the entire view hierarchy have been built programmatically. It is not in the xib.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
1
Boosts
0
Views
248
Activity
1w
Styling LabeledContent inside a Form on macOS?
On macOS 26, the Label part of a LabeledContent control and the Section.header part of a Section do not seem to honour view modifiers like .controlSize(.small) when used inside a Form with .formStyle(.grouped). Is there a way to make them respect the control size? Example: Form { Section("Details") { LabeledContent("Company", value: "Apple") } } .formStyle(.grouped) .controlSize(.small) // This only effects 'Apple' This produces a view where the value "Apple" is using a smaller font size but the label and the section header are not. I've tried (I think) almost every variation I can think of in terms of creating a LabeledContent and applying .controlSize but all of them come up short. The Form appears to always override my view modifiers for the section heading and label. Example 2: Form { Section { LabeledContent { Text("Company") .controlSize(.small) // Has no effect. } label: { Text("Apple") // Correctly resized to .small. } } header: { Text("Details") .controlSize(.small) // Has no effect. } } .formStyle(.grouped) .controlSize(.small) The best I've been able to come up with is a custom LabeledContentStyle that manually applies the layout and the styling, but that requires I explicitly "recreate" the macOS look-and-feel of left aligned labels and right aligned values by way of an HStack and Spacer. Have I overlooked a way to style a Form or LabeledContent that would provide the results I'm looking for?
Replies
0
Boosts
0
Views
47
Activity
1w
How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print("viewDidLayout: \(view.bounds.size)") } override func viewDidAppear() { print("viewDidAppear: \(view.bounds.size)") } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print("onAppear: \(geo.size)") } .onChange(of: geo.size) { print("onChange: \(geo.size)") } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Without rerunning on every layout or geometry change Question What is the proper macOS-native way to perform one-time startup logic only after the final restored window size is available? Is there a recommended lifecycle hook or pattern for this? Also, is it expected behavior that onAppear / viewDidAppear reports the pre-restoration size, or is it a bug?
Replies
3
Boosts
0
Views
192
Activity
1w
Crash while running NSAlert.runModal
My application overrides AppDelegate.menuWillOpen(). During startup of the application (in AppDelegate.applicationDidFinishLaunching) I attempt to install a privileged helper tool using SMAppService. On detecting that the tool needs to be allowed/installed I open the Login Items & Extensions settings and then display a modal dialog, advising the user to authorise the privileged helper. Then the application crashes with a message in the crash file Application Specific Information: BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively Maybe I could avoid this by removing the menuWillOpen() override so am looking for a workaround. i.e. is it possible to install the override function programmatically later during initialisation, rather then declaring it in an extension. I have attached the crash log. ChronyControl-2026-04-29-111332.crash
Replies
4
Boosts
0
Views
631
Activity
1w
ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
When I set up a toolbar item group with multiple options and set the controlGroupStyle as .palette, and when one of the options are supposed to present a view controller, I get the following error Attempt to present <UINavigationController: 0x101813200> on <ProjectName.HomeTabBarViewController: 0x10701bc00> (from <UINavigationController: 0x107821000>) which is already presenting <_UIContextMenuActionsOnlyViewController: 0x1035c19d0>. So basically the context menu we see is under the hood a view controller that is being presented. Is there a right way of fixing it, or is it maybe something that will be fixed by Apple? This is how I set up the ToolbarItemGroup on SwiftUI and the view model ultimately presents another UINavigationController that has a UIHostingController as its view controller: .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { Button("ft_commons_edit".localised, systemImage: "pencil") { viewModel.didTapEditAction() } Button("ft_commons_delete".localised, systemImage: "trash") { viewModel.didTapDeleteAction() } } label: { Image("edit-icon") .resizable() .frame(width: 24.0, height: 24.0) } } .controlGroupStyle(.palette) This is how the view looks like when presentation fails: As a workaround, I found two options that work well. I’d like to share them and ask for recommendations, just to make sure they won’t cause any unexpected issues later on: Option 1: Access the top most visible view controller and attempt presenting on it This requires the following extension: extension UIViewController { func topMostViewController() -> UIViewController { if let presentedViewController = self.presentedViewController { return presentedViewController.topMostViewController() } else if let navigationController = self as? UINavigationController, let topViewController = navigationController.topViewController { return topViewController.topMostViewController() } else if let tabBarController = self as? UITabBarController, let selectedViewController = tabBarController.selectedViewController { return selectedViewController.topMostViewController() } else { return self } } } Then called as: navigationController.topMostViewController().present(exerciseEditingNavController, animated: true) Option 2: Call dismiss before attempting to present anything This also works fine, even without any delay, the menu is first dismissed and presentation works fine afterwards, code example: navigationController.dismiss(animated: true) navigationController.present(exerciseEditingNavController, animated: true) I feel like Option 1 would be the better choice, because if this context menu is ever no longer treated as a view controller and direct presentation starts working, Option 1 would still behave correctly by presenting from the topmost visible view controller. Option 2, on the other hand, could introduce a bug by dismissing an unrelated view controller if the context menu is no longer represented as a view controller at that point. I would appreciate any advice from anyone who has experienced this, or from Apple developers. Thanks
Replies
6
Boosts
0
Views
328
Activity
1w
After binding to NSBrowser indexPaths the browser assumes I'm using NSBrowserCell and calls unimplemented methods on my NSCell subclass
So after binding to NSBrowser selectionIndexPaths: https://developer.apple.com/library/archive/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSBrowser.html this causes NSBrowser to do some weird stuff that seems completely unrelated to this particular binding. It starts calling NSBrowserCell methods on my cells but my cell is not a NSBrowserCell. My cell is actually a subclass of NSTextFieldCell. But NSBrowser starts sending setIsLeaf: (which I don't implement). In any case if I implement the -setLeaf: that solves that unrecognized selector, but now my cells don't draw titles. Not sure why binding to selectionIndexPaths causes this behavior? The cell stuff seems unrelated to this particular binding. I am of course using the newer but still pretty old item based APIs... do these bindings only support using NSMatrix? I do set the binding after calling -setCellClass: but makes no difference. I also just tried overriding -setSelectionIndexPaths: but NSBrowser does not use the setter.
Replies
0
Boosts
0
Views
94
Activity
1w