From 9f58e89472ba6a63b4710eb52b770a8fa662326f Mon Sep 17 00:00:00 2001 From: nExmond Date: Thu, 10 Nov 2022 16:02:26 +0900 Subject: [PATCH] Use at least one scene even if the conditions are not met --- Source/Infra/EKWindow.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Infra/EKWindow.swift b/Source/Infra/EKWindow.swift index d7cd1280..590c5f51 100644 --- a/Source/Infra/EKWindow.swift +++ b/Source/Infra/EKWindow.swift @@ -15,7 +15,9 @@ class EKWindow: UIWindow { init(with rootVC: UIViewController) { if #available(iOS 13.0, *) { // TODO: Patched to support SwiftUI out of the box but should require attendance - if let scene = UIApplication.shared.connectedScenes.filter({$0.activationState == .foregroundActive}).first as? UIWindowScene { + let scenes = UIApplication.shared.connectedScenes + let candidateScene = scenes.first { $0.activationState == .foregroundActive } ?? scenes.first + if let scene = candidateScene as? UIWindowScene { super.init(windowScene: scene) } else { super.init(frame: UIScreen.main.bounds)