Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 7d0c5b3

Browse files
committed
Set window in demo app AppDelegate to avoid SVProgressHUD crash
1 parent 1d28011 commit 7d0c5b3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Demo/AuthenticatorDemo/AppDelegate.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import UIKit
33
@main
44
class AppDelegate: UIResponder, UIApplicationDelegate {
55

6+
// This is a property defined in `UIApplicationDelegate`. In modern UIKit apps,
7+
// `UISceneConfiguration` is responsible for creating and holding the window.
8+
//
9+
// However, we need to set this anyway because SVProgressHUD accesses it internally and will
10+
// crash the app if the value it finds is nil.
11+
var window: UIWindow?
12+
613
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
714
return true
815
}

Demo/AuthenticatorDemo/SceneDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1010
window = UIWindow(windowScene: scene)
1111
window?.rootViewController = UINavigationController(rootViewController: ViewController())
1212
window?.makeKeyAndVisible()
13+
14+
// We need to set this relationship to avoid a crash when using SVProgressHUD.
15+
(UIApplication.shared.delegate as? AppDelegate)?.window = window
1316
}
1417
}

0 commit comments

Comments
 (0)