diff --git a/Sources/Hammer/Utilties/UIKit+Extensions.swift b/Sources/Hammer/Utilties/UIKit+Extensions.swift index 2a1da24..933b251 100644 --- a/Sources/Hammer/Utilties/UIKit+Extensions.swift +++ b/Sources/Hammer/Utilties/UIKit+Extensions.swift @@ -46,6 +46,10 @@ extension UIDevice { extension UIWindow { convenience init(wrapping viewController: UIViewController) { self.init(frame: UIScreen.main.bounds) + if #available(iOS 13.0, *), self.windowScene == nil { + self.windowScene = UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene }.first + } self.rootViewController = viewController } } diff --git a/TestHost/Info.plist b/TestHost/Info.plist index 57724db..3793d4c 100644 --- a/TestHost/Info.plist +++ b/TestHost/Info.plist @@ -41,5 +41,22 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneConfigurationName + Default Configuration + + + + diff --git a/TestHost/SceneDelegate.swift b/TestHost/SceneDelegate.swift new file mode 100644 index 0000000..8a02b95 --- /dev/null +++ b/TestHost/SceneDelegate.swift @@ -0,0 +1,8 @@ +import UIKit + +@available(iOS 13.0, *) +final class SceneDelegate: UIResponder, UISceneDelegate { + var window: UIWindow? + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions) {} +} diff --git a/Tests/HammerTests/KeyboardTests.swift b/Tests/HammerTests/KeyboardTests.swift index cea742f..19f62f7 100644 --- a/Tests/HammerTests/KeyboardTests.swift +++ b/Tests/HammerTests/KeyboardTests.swift @@ -1,4 +1,4 @@ -import Hammer +@testable import Hammer import UIKit import XCTest @@ -187,8 +187,7 @@ final class KeyboardTests: XCTestCase { view.centerXAnchor.constraint(equalTo: viewController.view.centerXAnchor), ]) - let window = UIWindow(frame: UIScreen.main.bounds) - window.rootViewController = viewController + let window = UIWindow(wrapping: viewController) window.isHidden = false let eventGenerator = try EventGenerator(window: window)