From 2a369e38bd96a9523269a1416dc669c253751586 Mon Sep 17 00:00:00 2001 From: shailantani Date: Fri, 11 Sep 2026 16:50:17 +0530 Subject: [PATCH] iOS: adopt UIScene lifecycle for Xcode 26+ / iOS 26+ SDK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apps built with the iOS 26+ SDK must adopt the UIScene-based app lifecycle; the AppDelegate-only lifecycle this project's iOS shell uses is no longer supported and crashes on launch: Application failed to launch: UIScene life cycle is required for apps built with this SDK. This adds a SceneDelegate (window/root VC still come from Main.storyboard, it just forwards deep links / Universal Links to Capacitor's ApplicationDelegateProxy, since AppDelegate's own open-url/continue-activity callbacks aren't invoked under the scene lifecycle), wires AppDelegate's application(_:configurationForConnecting:) to use it, and adds the UIApplicationSceneManifest to Info.plist. No deployment target, bundle id, or signing settings changed — apps built with older Xcode/SDKs are unaffected. Co-Authored-By: Claude Sonnet 5 --- .../ios/App/App.xcodeproj/project.pbxproj | 4 ++++ frontend/ios/App/App/AppDelegate.swift | 13 ++++++++++-- frontend/ios/App/App/Info.plist | 21 +++++++++++++++++-- frontend/ios/App/App/SceneDelegate.swift | 21 +++++++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 frontend/ios/App/App/SceneDelegate.swift diff --git a/frontend/ios/App/App.xcodeproj/project.pbxproj b/frontend/ios/App/App.xcodeproj/project.pbxproj index 89cd930..1ba5f1c 100644 --- a/frontend/ios/App/App.xcodeproj/project.pbxproj +++ b/frontend/ios/App/App.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; + AA0000000000000000000002 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0000000000000000000001 /* SceneDelegate.swift */; }; 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; @@ -22,6 +23,7 @@ 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + AA0000000000000000000001 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -75,6 +77,7 @@ children = ( 50379B222058CBB4000EE86E /* capacitor.config.json */, 504EC3071FED79650016851F /* AppDelegate.swift */, + AA0000000000000000000001 /* SceneDelegate.swift */, 504EC30B1FED79650016851F /* Main.storyboard */, 504EC30E1FED79650016851F /* Assets.xcassets */, 504EC3101FED79650016851F /* LaunchScreen.storyboard */, @@ -210,6 +213,7 @@ buildActionMask = 2147483647; files = ( 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + AA0000000000000000000002 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/frontend/ios/App/App/AppDelegate.swift b/frontend/ios/App/App/AppDelegate.swift index c3cd83b..a513a30 100644 --- a/frontend/ios/App/App/AppDelegate.swift +++ b/frontend/ios/App/App/AppDelegate.swift @@ -4,13 +4,22 @@ import Capacitor @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + let sceneConfiguration = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + sceneConfiguration.delegateClass = SceneDelegate.self + return sceneConfiguration + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + } + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. diff --git a/frontend/ios/App/App/Info.plist b/frontend/ios/App/App/Info.plist index 1987307..c06987b 100644 --- a/frontend/ios/App/App/Info.plist +++ b/frontend/ios/App/App/Info.plist @@ -24,8 +24,25 @@ UILaunchStoryboardName LaunchScreen - UIMainStoryboardFile - Main + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + UIRequiredDeviceCapabilities armv7 diff --git a/frontend/ios/App/App/SceneDelegate.swift b/frontend/ios/App/App/SceneDelegate.swift new file mode 100644 index 0000000..151cfb4 --- /dev/null +++ b/frontend/ios/App/App/SceneDelegate.swift @@ -0,0 +1,21 @@ +import UIKit +import Capacitor + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + // The window and root view controller are created automatically from + // Main.storyboard via the UISceneStoryboardFile key in Info.plist. + // These callbacks just forward deep links / Universal Links to Capacitor, + // since AppDelegate's equivalents are not called under the scene lifecycle. + + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + guard let url = URLContexts.first?.url else { return } + _ = ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: [:]) + } + + func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { + _ = ApplicationDelegateProxy.shared.application(UIApplication.shared, continue: userActivity) { _ in } + } +}