I'm using the following code to add a new menu item programatically
override func viewDidLoad() {
let mainMenu = NSApp.mainMenu
let myMenu = NSMenuItem(title: "MenuTitle", action: nil, keyEquivalent: "")
mainMenu!.addItem(myMenu)
}
But this does not add a new menu item.
You need to set your menuItem submenu and add new menu items to it as follow: