App delegate methods aren't being called in iOS 13
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
App Delegate Methods Aren't Being Called in iOS 13
The introduction of iOS 13 brought a multitude of changes to Apple's mobile operating system, enhancing user experience and developer capabilities. However, with these advancements, some developers encountered issues with app delegate methods not being called as expected. This article delves into the reasons behind these issues, solutions, and best practices to adapt to the changes in iOS 13.
Background
The App Delegate is a cornerstone of an iOS app, acting as the central point of control and coordination. It responds to key app life cycle events such as app launch, state transitions, and notifications. Traditionally, these interactions are managed through methods provided by the `UIApplicationDelegate` protocol, such as:
- `application(_:didFinishLaunchingWithOptions:)`
- `applicationWillResignActive(_:)`
- `applicationDidEnterBackground(_:)`
- `applicationWillEnterForeground(_:)`
- `applicationDidBecomeActive(_:)`
- `applicationWillTerminate(_:)`
The Problem in iOS 13
In iOS 13, some developers observed that certain app delegate methods were not being called. This behavior is primarily due to the introduction of Scene Delegates and changes in the app life cycle management.
Scene Delegates: An Overview
iOS 13 introduced the concept of multi-window support on iPadOS and improved multitasking on iOS. To accommodate this, Apple introduced `UISceneDelegate`, offloading some responsibilities from the App Delegate to individual scene delegates. This change means that the app delegate no longer handles UI-related events; instead, scene delegates manage them.
Key methods moved to `UISceneDelegate` include:
- `scene(_:willConnectTo:options:)`
- `sceneDidDisconnect(_:)`
- `sceneDidBecomeActive(_:)`
- `sceneWillResignActive(_:)`
- `sceneWillEnterForeground(_:)`
- `sceneDidEnterBackground(_:)`
Adapting to Scene Delegate Architecture
Updating the Project
When creating a new project in Xcode targeting iOS 13 or later, Xcode initializes the template with both an App Delegate and a Scene Delegate. However, existing projects upgraded to iOS 13 may require manual adjustments.
Modifying the `Info.plist`
The presence of a scene delegate is indicated in the app’s `Info.plist` file:

