Thursday, June 23, 2022

Testing SwiftUI for Mac After WWDC 2022

Sarah Reichelt (tweet):

In December 2019, I wrote a series of articles about using SwiftUI to build a Mac app. And in July 2020, I re-visited the sample app to apply the new SwiftUI features made available in macOS BigSur. Now that macOS Ventura and Xcode 14 are in beta, it’s time to build the app again while learning how to incorporate the new APIs.

[…]

macOS apps can have multiple windows open at once, and in previous iterations of SwiftUI, it has been difficult to detect the active one. Last year, we got @FocusedBinding but it didn’t really work. This year it works, but we also have a new EnvironmentValue called controlActiveState.

[…]

This year, we have a new method that uses another new EnvironmentValue called openWindow. […] If you create a Window scene instead of a WindowGroup, not only does this become a single presentation window, but you get a menu item for it in the Window menu without any extra work. You can add a keyboard shortcut to the Window scene too. Supposedly, you can add default sizing and positioning, but they don’t appear to work yet.

[…]

I achieved something I was unable to do last time and that is to make the text edit field have focus when the view opens.

Previously:

Update (2022-06-24): Thomas Clement:

Unfortunately, [List has the] same terrible perf in Ventura.

Update (2022-07-05): See also: Hacker News.

Comments RSS · Twitter

Leave a Comment