<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ExtensionKit",
  "identifier" : "/documentation/ExtensionKit/AppExtensionScene",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "ExtensionKit"
    ],
    "preciseIdentifier" : "s:12ExtensionKit03AppA5SceneP"
  },
  "title" : "AppExtensionScene"
}
-->

# AppExtensionScene

An interface you use to provide a specific scene from your app extension’s UI.

```
@MainActor @preconcurrency protocol AppExtensionScene
```

## Overview

When your app extension provides custom UI, use this type to define a specific scene
for that UI. An app extension can define multiple scene types in coordination with the
host app. When the host app displays the app extension’s UI, it provides a unique string
identifier for the scene it wants to display. The app extension responds by providing
an instance of this type that contains that scene’s contents.

When defining a scene, provide the body of that scene using the [`PrimitiveAppExtensionScene`](/documentation/ExtensionKit/PrimitiveAppExtensionScene)
type. This type contains the unique identifier of the scene and the content to display. The
following code shows an implementation of a scene capable of displaying content you supply at
initialization time using a closure. The scene’s [`body`](/documentation/ExtensionKit/AppExtensionScene/body-swift.property) property repackages that content
inside the [`PrimitiveAppExtensionScene`](/documentation/ExtensionKit/PrimitiveAppExtensionScene) structure. You can also use this type to accept
a scene-specific XPC connection, which you might use to communicate custom data related
to managing UI-related interactions.

```
struct MyScene<Content: View>: AppExtensionScene {

    public init(content: @escaping () ->  Content) {
        self.content = content
    }

    private let content: () -> Content

    public var body: some AppExtensionScene {
        PrimitiveAppExtensionScene(id: “MyScene”) {
            content()
        } onConnection: { connection in
            // TODO: Configure the XPC connection and return true
            return false
        }
    }
}
```

For more information about creating UI-based app extensions, see
<doc://com.apple.documentation/documentation/ExtensionKit/including-extension-based-ui-in-your-interface>.

## Topics

### Configuring the app extension

[`var body: Self.Body`](/documentation/ExtensionKit/AppExtensionScene/body-swift.property)

The content and behavior of the scene’s interface.

[`associatedtype Body : AppExtensionScene`](/documentation/ExtensionKit/AppExtensionScene/Body-swift.associatedtype)

The type for this scene’s body.

## Relationships

### Conforming Types

[`PrimitiveAppExtensionScene`](/documentation/ExtensionKit/PrimitiveAppExtensionScene)

---

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)