I store a reference of the SceneDelegate in a static weak
property and initialise it in scene(:willConnectTo:options)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
static weak var shared: SceneDelegate?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
Self.shared = self
}
}
Later, scene can be accessed using SceneDelegate.shared
NoteUPDATE: As mentioned in the comments, this solution will only work for apps that deal with only one scene. Apps that run on iPhone typically have only one scene. iPad apps can have multiple scenes.