I'm writing a mac os targeted game engine in swift. Im using metal for rendering and cocoa for handling the window. The entire app is being made programmatically. I'm not using a storyboard or any xibs
I have this file: Window.swift
import Cocoa
class Window : NSObject
{
let width, height : Int
let title : String
let size : CGSize
let rect : NSRect
let window : NSWindow
init(width : Int, height: Int, title: String) {
self.width = width
self.height = height
self.title = title
self.size = CGSize(width: width, height: height)
self.rect = NSRect(origin: .zero, size: size)
self.window = NSWindow(contentRect: rect, styleMask:
.closable, backing: .buffered, defer: false)
}
func createWindow()
{
window.title = title
window.isOpaque = false
window.center()
window.isMovableByWindowBackground = true
window.backgroundColor = NSColor.gray
window.makeKeyAndOrderFront(window)
}
}
And this is main.swift
let window = Window.init(width: 1280, height: 720, title: "Serious")
window.createWindow()
This code seems fine but for some reason i get this error: 2020-03-25 10:34:49.719557-0700 GameEngine[1355:50613] [default] 0 is not a valid connection ID. 2020-03-25 10:34:49.727881-0700 GameEngine[1355:50613] [default] 0 is not a valid connection ID. 2020-03-25 10:34:49.728046-0700 GameEngine[1355:50613] [default] 0 is not a valid connection ID. Program ended with exit code: 0