Skip to content

Instantly share code, notes, and snippets.

@gonsolo
Last active April 21, 2022 18:13
Show Gist options
  • Save gonsolo/dd83654c0180fdda424756a59a6f66ad to your computer and use it in GitHub Desktop.
Save gonsolo/dd83654c0180fdda424756a59a6f66ad to your computer and use it in GitHub Desktop.
Swift 4 macOS Window Hello World
// Hello World Window macOS Swift 4: Creates an empty window
import AppKit
let nsapp = NSApplication.shared
let rect = NSMakeRect(0, 0, 200, 200)
if #available(macOS 10.10, *) {
let window = NSWindow(contentRect: rect,
styleMask: .fullSizeContentView,
backing: NSWindow.BackingStoreType.buffered,
defer: false)
window.makeKeyAndOrderFront(nil)
}
nsapp.run()
<plist><dict/></plist>
TARGET=HelloWindow
all: $(TARGET)
t: test
test: $(TARGET)
./$(TARGET)
$(TARGET): $(TARGET).swift
swiftc -o $(TARGET) $(TARGET).swift
e: edit
edit:
vi $(TARGET).swift
c: clean
clean:
rm -f $(TARGET) *.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment