Skip to content

Commit 3b14b2e

Browse files
committed
Add support for iOS UIScene API and enable multi-scene configurations in Info.plist
1 parent a04ac93 commit 3b14b2e

File tree

2 files changed

+45
-6
lines changed

2 files changed

+45
-6
lines changed

sample/iosApp/iosApp/Info.plist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
<dict>
55
<key>CADisableMinimumFrameDurationOnPhone</key>
66
<true/>
7+
8+
<key>UIApplicationSceneManifest</key>
9+
<dict>
10+
<key>UIApplicationSupportsMultipleScenes</key>
11+
<false/>
12+
<key>UISceneConfigurations</key>
13+
<dict>
14+
<key>UIWindowSceneSessionRoleApplication</key>
15+
<array>
16+
<dict>
17+
<key>UISceneConfigurationName</key>
18+
<string>Default Configuration</string>
19+
<key>UISceneDelegateClassName</key>
20+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
21+
<key>UISceneClassName</key>
22+
<string>UIWindowScene</string>
23+
</dict>
24+
</array>
25+
</dict>
26+
</dict>
27+
728
<key>NSAppTransportSecurity</key>
829
<dict>
930
<key>NSAllowsArbitraryLoads</key>

sample/iosApp/iosApp/iosApp.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,35 @@ import ComposeApp
33

44
@main
55
class AppDelegate: UIResponder, UIApplicationDelegate {
6-
var window: UIWindow?
76

87
func application(
98
_ application: UIApplication,
109
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
1110
) -> Bool {
12-
window = UIWindow(frame: UIScreen.main.bounds)
13-
if let window = window {
14-
window.rootViewController = MainKt.MainViewController()
15-
window.makeKeyAndVisible()
16-
}
11+
// Additional initialization if needed
1712
return true
1813
}
14+
15+
// Provide a scene configuration for connecting scenes (iOS 13+)
16+
func application(_ application: UIApplication,
17+
configurationForConnecting connectingSceneSession: UISceneSession,
18+
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
19+
let config = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
20+
config.delegateClass = SceneDelegate.self
21+
config.sceneClass = UIWindowScene.self
22+
return config
23+
}
24+
}
25+
26+
// MARK: - UIScene support
27+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
28+
var window: UIWindow?
29+
30+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
31+
guard let windowScene = scene as? UIWindowScene else { return }
32+
let window = UIWindow(windowScene: windowScene)
33+
window.rootViewController = MainKt.MainViewController()
34+
window.makeKeyAndVisible()
35+
self.window = window
36+
}
1937
}

0 commit comments

Comments
 (0)