To create a SwiftUI app using NSApplication, you can follow these steps:
AppDelegate.swift
file.AppDelegate.swift
file to create a new instance of NSApplication
and make it the shared application:main.swift1174 chars36 lines
This code creates a NSWindow
from the ContentView
struct defined in ContentView.swift
, and sets it as the content view of the NSHostingView
object.
Finally, it creates a new instance of NSApplication
, sets its activation policy to regular, activates it, and runs it.
That's it! You can now build and run your app to see the NSWindow
containing your SwiftUI view.
gistlibby LogSnag