I have a SwiftUI view MySwiftUIView:
import SwiftUI struct MySwiftUIView: View { var body: some View { Text("Hello, World!") } } I want to use it as part of an AppKit view. I tried the following code:
import Cocoa import SwiftUI class MyViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() self.view.addSubview( NSHostingView(rootView: MySwiftUIView()) ) } } with the corresponding storyboard:
After the code is built, the result is an empty window:
What I want is this:
How should I make this happen?


