---
title: UIHostingSceneDelegate
framework: swiftui
role: symbol
role_heading: Protocol
path: swiftui/uihostingscenedelegate
---

# UIHostingSceneDelegate

Extends UIKit/UISceneDelegate to bridge SwiftUI scenes.

## Declaration

```swift
protocol UIHostingSceneDelegate : UISceneDelegate
```

## Overview

Overview Declare any SwiftUI scenes you wish to activate from UIKit in the static rootScene property of your conforming class: class HostingSceneDelegate: UIHostingSceneDelegate {     static var rootScene: some Scene {         WindowGroup(id: "swiftui-window") {             ContentView()         }     }

// Add UISceneDelegate lifecycle callbacks here } Use a class conforming to UIHostingSceneDelegate to  activate a scene by its ID or presented value with UISceneSessionActivationRequest: if let requestWithID = UISceneSessionActivationRequest(     hostingDelegateClass: HostingSceneDelegate.self,     id: "swiftui-window" ) {     UIApplication.shared.activateSceneSession(for: requestWithID) }

if let requestWithData = UISceneSessionActivationRequest(     hostingDelegateClass: HostingSceneDelegate.self,     value: FavoriteNumber(13) ) {     UIApplication.shared.activateSceneSession(for: requestWithData) } When a SwiftUI scene declared in your rootScene property is activated, an instance of your conforming class will be created by SwiftUI and receive window scene lifecycle callbacks. Your UIHostingSceneDelegate class can be used with a UISceneConfiguration in your app delegate’s application(_:configurationForConnecting:options:)method to activate a SwiftUI scene in response to an external event: class AppDelegate: UIApplicationDelegate {

func application(         _ app: UIApplication,         configurationForConnecting sceneSession: UISceneSession,         options: UIScene.ConnectionOptions     ) -> UISceneConfiguration {         let config = UISceneConfiguration(             name: nil, sessionRole: sceneSession.role)         config.delegateClass = HostingSceneDelegate.self         return config     }

}

## Topics

### Associated Types

- [RootScene](swiftui/uihostingscenedelegate/rootscene-swift.associatedtype.md)

### Type Properties

- [rootScene](swiftui/uihostingscenedelegate/rootscene-swift.type.property.md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [UISceneDelegate](uikit/uiscenedelegate.md)

## See Also

### Displaying SwiftUI views in UIKit

- [Using SwiftUI with UIKit](uikit/using-swiftui-with-uikit.md)
- [Unifying your app’s animations](swiftui/unifying-your-app-s-animations.md)
- [UIHostingController](swiftui/uihostingcontroller.md)
- [UIHostingControllerSizingOptions](swiftui/uihostingcontrollersizingoptions.md)
- [UIHostingConfiguration](swiftui/uihostingconfiguration.md)
