SwiftUI - cannot find type 'UIApplicationDelegate' in scope

Viewed 3399

I am new to MacOS development and Swift so sorry if this is a basic/stupid question.

I am getting this error:

Cannot find type 'UIApplicationDelegate' in scope

I have created an AppDelegate.swift file to try to define a default window size for my app. I have this code:

import Foundation
import SwiftUI

class AppDelegate: NSObject, UIApplicationDelegate {
    window = NSWindow(
            contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
            styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
            backing: .buffered, defer: false)
        window.center()
        window.setFrameAutosaveName("Main Window")
        window.contentView = NSHostingView(rootView: ContentView())
        window.makeKeyAndOrderFront(nil)
}

I'm not really sure what to do here. Is there something I need to import?

Thnak you for your help.

0 Answers
Related