<!--
{
  "availability" : [
    "macOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/NSHostingSceneRepresentation",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI28NSHostingSceneRepresentationC"
  },
  "title" : "NSHostingSceneRepresentation"
}
-->

# NSHostingSceneRepresentation

An AppKit type that hosts and can present SwiftUI scenes

```
@MainActor class NSHostingSceneRepresentation<Content> where Content : Scene
```

## Overview

Use instances of this type with `NSApplication.addSceneRepresentation(_:)`
to include SwiftUI scene functionality in an app which uses the AppKit
app lifecycle.

For example, you can add a `Settings` scene to your app and present it when
the corresponding menu item is selected:

```
import AppKit
import SwiftUI

@main
class ApplicationDelegate: NSApplicationDelegate {
    let settingsScene = NSHostingSceneRepresentation {
        Settings {
            SettingsView()
        }
    }

    func applicationWillFinishLaunching(_ notification: Notification) {
        NSApplication.shared.addSceneRepresentation(settingsScene)
    }

    @IBAction func showAppSettings(_ sender: NSMenuItem) {
        settingsScene.environment.openSettings()
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)