Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppprt scenes based apps #55

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Hammer/Utilties/UIKit+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
17 changes: 17 additions & 0 deletions TestHost/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,22 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
8 changes: 8 additions & 0 deletions TestHost/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -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) {}
}
5 changes: 2 additions & 3 deletions Tests/HammerTests/KeyboardTests.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Hammer
@testable import Hammer
import UIKit
import XCTest

Expand Down Expand Up @@ -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)
Expand Down
Loading