<!--
{
  "availability" : [
    "macOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplication/addSceneRepresentation(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "s:So13NSApplicationC7SwiftUIE22addSceneRepresentationyyAC09NSHostingeF0CyxGAC0E0RzlF"
  },
  "title" : "addSceneRepresentation(_:)"
}
-->

# addSceneRepresentation(_:)

Adds the specified SwiftUI scene representation to the current
application.

```
@MainActor @preconcurrency func addSceneRepresentation<C>(_ representation: NSHostingSceneRepresentation<C>) where C : Scene
```

## Discussion

Scenes defined by the representation can be presented programmatically
via the environment actions available on `NSHostingSceneRepresentation`,
or when the app receives an external event such as a URL.

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 scene = NSHostingSceneRepresentation {
        Settings {
            SettingsView()
        }
    }

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

    @IBAction func showAppSettings(_ sender: NSMenuItem) {
        scene.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)