Here is a working example without bells whistles, updated to Swift 4.2.
Creates a bare window with & without tip, depending on what function you call.
In IB, uncheck the "start controller" everywhere. For the pen version to work, you must provide the "WindowController" storyboard ID in the supplied IB window controller.
import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate, DebugHelper { var myName: String = "AppDelegate" var windowController: NSWindowController! var window: NSWindow! func applicationDidFinishLaunching(_ aNotification: Notification) { //nib() diy() } func nib() { let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil) guard let wc = storyboard.instantiateController(withIdentifier: "WindowController") as? NSWindowController else { return } windowController = wc wc.showWindow(self) } func diy() { window = NSWindow() window.styleMask = NSWindow.StyleMask(rawValue: 0xf) window.backingType = .buffered window.contentViewController = ViewController() window.setFrame(NSRect(x: 700, y: 200, width: 500, height: 500), display: false) windowController = NSWindowController() windowController.contentViewController = window.contentViewController windowController.window = window windowController.showWindow(self) } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } } import Cocoa class ViewController: NSViewController, DebugHelper { var myName: String = "ViewController" override func loadView() { view = NSView() } }
source share