I'm building a Mac OSX Menubar app (build target is 14.0) and need a Settings window as part of it. I define the window as a standalone view in my @main block as follows:
struct xyzApp: App {
MenuBarExtra {
MenubarView()
} label: {
Label("XYZ", image: "xyz")
}
.menuBarExtraStyle(.window)
Window("Settings", id: "settings-window") {
SettingsView()
}.windowResizability(.contentSize)
}
The Settings view looks like this
var body: some View {
TabView {
Form {
}.tabItem { Label("Tab1",systemImage: "gear") }
Form {
}.tabItem { Label("Tab2",systemImage: "gear") }
}
}
}
However the Tabview is not being rendered correctly, there's no image and the sizing is wrong
I tested the same code on a regular app with a Settings() declaration in the @main block and it works fine. Any points on what I'm doing wrong would be very helpful.
Thanks!
Ok figured it out. It turns out that macos only supports TabView on Settings windows! I worked around this by using SettingsLink to open the Settings window after defining it as follows in my @main block
Settings {
SettingsView()
}
This is a pretty irritating limitation, hopefully it gets fixed in future releases.