• Create xib-based NSWindowController, change NSWindo custom class to component class name of your exported.
  • Create xib-based ViewController, Select it's xib interface, Drag a button into the view, and change button title to "Show Window".
  • Declare panel variable in the controller class.
  • Define a function called showWindowAction, Connect button action to it, in where you can write show window code.

The reference code is implemented as follows:

import Cocoa
class ViewController: NSViewController {

    override func viewDidLoad() {
        // Do view setup here.
    lazy var hdWindowController: WindowController = {
        let windowVC = WindowController()
        return windowVC
    @IBAction func showWindowAction(_ sender: Any) {