What is the iOS app lifecycle?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Swift & iOS basics — a prerequisite for any developer role.

Answer

The iOS app lifecycle describes the states an app goes through from launch to termination. Understanding it is essential for proper resource management. App states: (1) Not Running: app hasn't been launched or was terminated by the system; (2) Inactive: app is in foreground but not receiving events (briefly, during transition); (3) Active: app is in the foreground and receiving events — the normal running state; (4) Background: app is not visible but executing code. Limited time (~30 seconds); (5) Suspended: app is in background but not executing — kept in memory; system may terminate without notice. SceneDelegate (iOS 13+) lifecycle methods: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) // Scene created func sceneDidBecomeActive(_ scene: UIScene) // App became active func sceneWillResignActive(_ scene: UIScene) // About to become inactive func sceneDidEnterBackground(_ scene: UIScene) // Entered background func sceneWillEnterForeground(_ scene: UIScene) // About to enter foreground func sceneDidDisconnect(_ scene: UIScene) // Scene removed. AppDelegate (older / shared): func applicationDidBecomeActive(_ application: UIApplication) func applicationWillResignActive(_ application: UIApplication) func applicationDidEnterBackground(_ application: UIApplication) func applicationWillEnterForeground(_ application: UIApplication) func applicationWillTerminate(_ application: UIApplication). Best practices: save state in sceneDidEnterBackground; release heavy resources in background; restore state in sceneWillEnterForeground; use UIApplication.shared.backgroundTask for background work completion.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Swift & iOS codebase.