test(ios): add logging to SceneDelegate to verify initialization

Added comprehensive logging to SceneDelegate:

SceneDelegate Logging:
- Logs when willConnectTo is called
- Logs window creation
- Logs ViewController instantiation
- Logs window setup completion
- Uses os_log, print, and NSLog for maximum visibility

Debugging:
- Verifies SceneDelegate is being called
- Confirms ViewController is being created
- Checks window setup process

Fixes:
- Initialization tracking: can see if SceneDelegate runs
- ViewController creation: confirms ViewController is instantiated
- Window setup: verifies window is configured

Result: Can now see the full initialization chain from SceneDelegate to ViewController
This commit is contained in:
Matthew Raymer
2025-11-11 21:18:54 -08:00
parent 2f285edec4
commit 3a21b710d7

View File

@@ -11,6 +11,7 @@
// //
import UIKit import UIKit
import os.log
/** /**
* Scene delegate for iOS 13+ scene-based lifecycle * Scene delegate for iOS 13+ scene-based lifecycle
@@ -20,6 +21,7 @@ import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate { class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow? var window: UIWindow?
private let logger = OSLog(subsystem: "com.timesafari.dailynotification", category: "SceneDelegate")
func scene( func scene(
_ scene: UIScene, _ scene: UIScene,
@@ -27,15 +29,41 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
options connectionOptions: UIScene.ConnectionOptions options connectionOptions: UIScene.ConnectionOptions
) { ) {
// Called when a new scene session is being created // Called when a new scene session is being created
guard let windowScene = (scene as? UIWindowScene) else { return } os_log("🔍 SceneDelegate: willConnectTo called", log: logger, type: .info)
print("🔍 SceneDelegate: willConnectTo called")
NSLog("🔍 SceneDelegate: willConnectTo called")
guard let windowScene = (scene as? UIWindowScene) else {
os_log("❌ SceneDelegate: Failed to get windowScene", log: logger, type: .error)
print("❌ SceneDelegate: Failed to get windowScene")
NSLog("❌ SceneDelegate: Failed to get windowScene")
return
}
os_log("✅ SceneDelegate: Creating window and ViewController", log: logger, type: .info)
print("✅ SceneDelegate: Creating window and ViewController")
NSLog("✅ SceneDelegate: Creating window and ViewController")
let window = UIWindow(windowScene: windowScene) let window = UIWindow(windowScene: windowScene)
self.window = window self.window = window
// Create and configure the view controller // Create and configure the view controller
os_log("🔍 SceneDelegate: Instantiating ViewController", log: logger, type: .info)
print("🔍 SceneDelegate: Instantiating ViewController")
NSLog("🔍 SceneDelegate: Instantiating ViewController")
let viewController = ViewController() let viewController = ViewController()
os_log("✅ SceneDelegate: ViewController created, setting as root", log: logger, type: .info)
print("✅ SceneDelegate: ViewController created, setting as root")
NSLog("✅ SceneDelegate: ViewController created, setting as root")
window.rootViewController = viewController window.rootViewController = viewController
window.makeKeyAndVisible() window.makeKeyAndVisible()
os_log("✅ SceneDelegate: Window made key and visible", log: logger, type: .info)
print("✅ SceneDelegate: Window made key and visible")
NSLog("✅ SceneDelegate: Window made key and visible")
} }
func sceneDidDisconnect(_ scene: UIScene) { func sceneDidDisconnect(_ scene: UIScene) {