NSDockTilePlugIn and dockMenu selector never returns

I have a class:

class MyDockTilePlugin: NSObject, NSDockTilePlugIn {

  func setDockTile(_ dockTile: NSDockTile?) { return }

  func dockMenu() -> NSMenu? {
    let menu = NSMenu()
    let it = NSMenuItem(title: "choose me!", action: #selector(self.selectDMIP(_:)), keyEquivalent: "")
    it.target = self
    menu.addItem(it)
    return menu
  }

  @objc func selectDMIP(_ sender: NSMenuItem) {
    print("you selected me!")
  }
}

and I follow the instructions to put it in a Bundle and copy it into the main app.

I run the main app. Change the Dock options to Keep in Dock. Quit the main app. Right-click the Dock icon. I get the menu, but when selected, it never prints "you selected me!"

What I do see after selecting the menu item is the plugin class reloading.

Any ideas how to capture the menu item selection?

sorry, should not have used the print. actually use Logger. Regardless, it never logs and the class reloads (resetting all variables to default).

MyDockTilePlugin is run by the system's com.apple.dock.external.extra.arm64, if it is relevant.

NSDockTilePlugIn and dockMenu selector never returns
 
 
Q