Prior to Ventura, my app that only has a Menu Item does not have a Storyboard but does have a custom main.swift as
import Foundation
import Cocoa
let app = NSApplication.shared
let delegate = AppDelegate()
app.delegate = delegate
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
And then in Info.plist, I added Application is agent (UIElement) YES so the app isn't displayed in the dock.
Occasionally, the app now crashes on start.
Is there documentation for creating a Menu item only macOS app without Storyboard?
It's typically crashing in _NSCGSDisplayConfigurationUpdateAndInvokeObservers or in _NSCGSDockMesageReceive.
Thanks,
Turns out it has nothing to do with main.swift. I have a dictionary defined as dict : [ CGWindowID : NSWindow]. if you do dict.removeValue(forKey: key)?.close() this double deallocates the NSWindow if dict[key] was the last strong reference.
Found this by instead of Run in Xcode, you do Profile and select Zombie and I found that this NSWindow reference count goes to -1. oops.