Skip to content

Instantly share code, notes, and snippets.

View kjoe07's full-sized avatar

Yoel Jimenez del Valle kjoe07

View GitHub Profile
@HiddenJester
HiddenJester / UnitTestingSceneDelegateGist.md
Last active January 17, 2025 19:31
Mocking SceneDelegate for Unit Tests on iOS 13

Replacing the SceneDelegate When Running Unit Tests

Overview

I've been working through the exercises in the excellent iOS Unit Testing by Example book by Jon Reid, which I highly recommend. However, the book is in beta at the moment and there are some curveballs thrown by iOS 13 that aren't handled in the text yet. Specifically, when I hit the section about using a testing AppDelegate class I thought "This is very good. But what about the SceneDelegate?"

In Chapter 4 the recommendation is to remove the @UIApplicationMain decoration and make a manual top-level call to UIApplicationMain. To wit:

import UIKit