Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add UIScene lifecycle to fix iOS app crash on boot with iOS 27+ (#2414)
Leendert de Borst6c94049e80a0
diff --git a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxprojindex f38ebfb13..a0d18b887 100644--- a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj+++ b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj@@ -40,6 +40,7 @@CE9A58FC2DBA982100CB0A4C /* RCTNativeVaultManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE9A58FB2DBA982100CB0A4C /* RCTNativeVaultManager.mm */; };CE9A5A022DBAAE5000CB0A4C /* RCTNativeVaultManager.h in Sources */ = {isa = PBXBuildFile; fileRef = CE9A58FA2DBA982100CB0A4C /* RCTNativeVaultManager.h */; };CED3AB3C2E70CF8700F3FDEB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED3AB3B2E70CF8700F3FDEB /* AppDelegate.swift */; };+ CED3AB3E2E70CF8700F3FDED /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED3AB3D2E70CF8700F3FDEC /* SceneDelegate.swift */; };CEE480922DBE86DD00F4A367 /* VaultStoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEE480872DBE86DC00F4A367 /* VaultStoreKit.framework */; };CEE4809C2DBE86DD00F4A367 /* VaultStoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEE480872DBE86DC00F4A367 /* VaultStoreKit.framework */; };CEE4809D2DBE86DD00F4A367 /* VaultStoreKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CEE480872DBE86DC00F4A367 /* VaultStoreKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };@@ -255,6 +256,7 @@CE9A58FB2DBA982100CB0A4C /* RCTNativeVaultManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTNativeVaultManager.mm; sourceTree = "<group>"; };CE9A5B662DBAE42B00CB0A4C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };CED3AB3B2E70CF8700F3FDEB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = AliasVault/AppDelegate.swift; sourceTree = "<group>"; };+ CED3AB3D2E70CF8700F3FDEC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SceneDelegate.swift; path = AliasVault/SceneDelegate.swift; sourceTree = "<group>"; };CEE480872DBE86DC00F4A367 /* VaultStoreKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VaultStoreKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };CEE480912DBE86DD00F4A367 /* VaultStoreKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VaultStoreKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };CEE4816A2DBE8AC800F4A367 /* VaultUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VaultUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };@@ -467,6 +469,7 @@isa = PBXGroup;children = (CED3AB3B2E70CF8700F3FDEB /* AppDelegate.swift */,+ CED3AB3D2E70CF8700F3FDEC /* SceneDelegate.swift */,962DE0FB93C9458BAFEEED60 /* AliasVault-Bridging-Header.h */,13B07FB51A68108700A75B9A /* Images.xcassets */,CE73B39F2DFC8A0C0081B6CB /* AliasVault.icon */,@@ -1378,6 +1381,7 @@buildActionMask = 2147483647;files = (CED3AB3C2E70CF8700F3FDEB /* AppDelegate.swift in Sources */,+ CED3AB3E2E70CF8700F3FDED /* SceneDelegate.swift in Sources */,CE9A5A022DBAAE5000CB0A4C /* RCTNativeVaultManager.h in Sources */,CE26D68F2DA7FCD2006DC04D /* VaultManager.swift in Sources */,CE9A58FC2DBA982100CB0A4C /* RCTNativeVaultManager.mm in Sources */,diff --git a/apps/mobile-app/ios/AliasVault/AppDelegate.swift b/apps/mobile-app/ios/AliasVault/AppDelegate.swiftindex 138593d28..39a1150b6 100644--- a/apps/mobile-app/ios/AliasVault/AppDelegate.swift+++ b/apps/mobile-app/ios/AliasVault/AppDelegate.swift@@ -8,9 +8,9 @@ import VaultStoreKit@mainclass AppDelegate: UIResponder, UIApplicationDelegate {var window: UIWindow?-+ private(set) var launchOptions: [UIApplication.LaunchOptionsKey: Any]?private var reactNativeDelegate: ReactNativeDelegate?- private var reactNativeFactory: ExpoReactNativeFactory?+ private(set) var reactNativeFactory: ExpoReactNativeFactory?func application(_ application: UIApplication,@@ -34,16 +34,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {reactNativeDelegate = delegatereactNativeFactory = factory+ self.launchOptions = launchOptions- window = UIWindow(frame: UIScreen.main.bounds)+ // The window is created and React Native is started in SceneDelegate (UIScene lifecycle).+ return true+ }- factory.startReactNative(- withModuleName: "main",- in: window,- launchOptions: launchOptions- )+ // MARK: - UIScene- return true+ func application(+ _ application: UIApplication,+ configurationForConnecting connectingSceneSession: UISceneSession,+ options: UIScene.ConnectionOptions+ ) -> UISceneConfiguration {+ let configuration = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)+ configuration.delegateClass = SceneDelegate.self+ return configuration}// MARK: - Test Support@@ -110,18 +116,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {}#endif- // MARK: - Linking API-- func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {- return RCTLinkingManager.application(application, open: url, options: options)- }-- // MARK: - Universal Links-- func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {- return RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)- }-// MARK: - Remote Notificationsfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {diff --git a/apps/mobile-app/ios/AliasVault/Info.plist b/apps/mobile-app/ios/AliasVault/Info.plistindex 6071cf6ad..8705b36ff 100644--- a/apps/mobile-app/ios/AliasVault/Info.plist+++ b/apps/mobile-app/ios/AliasVault/Info.plist@@ -97,6 +97,23 @@</array><key>RCTNewArchEnabled</key><true/>+ <key>UIApplicationSceneManifest</key>+ <dict>+ <key>UIApplicationSupportsMultipleScenes</key>+ <false/>+ <key>UISceneConfigurations</key>+ <dict>+ <key>UIWindowSceneSessionRoleApplication</key>+ <array>+ <dict>+ <key>UISceneConfigurationName</key>+ <string>Default Configuration</string>+ <key>UISceneDelegateClassName</key>+ <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>+ </dict>+ </array>+ </dict>+ </dict><key>UILaunchStoryboardName</key><string>SplashScreen</string><key>UIRequiredDeviceCapabilities</key>diff --git a/apps/mobile-app/ios/AliasVault/SceneDelegate.swift b/apps/mobile-app/ios/AliasVault/SceneDelegate.swiftnew file mode 100644index 000000000..9387ce9f2--- /dev/null+++ b/apps/mobile-app/ios/AliasVault/SceneDelegate.swift@@ -0,0 +1,62 @@+import UIKit+import React++/// UIKit requires the UIScene lifecycle for apps linked against the iOS 27 SDK, otherwise the app will crash on boot with iOS 27+ while it still works with iOS 26.+class SceneDelegate: UIResponder, UIWindowSceneDelegate {+ var window: UIWindow?++ func scene(+ _ scene: UIScene,+ willConnectTo session: UISceneSession,+ options connectionOptions: UIScene.ConnectionOptions+ ) {+ guard let windowScene = scene as? UIWindowScene else { return }+ guard let appDelegate = UIApplication.shared.delegate as? AppDelegate,+ let factory = appDelegate.reactNativeFactory else {+ fatalError("SceneDelegate: React Native factory is not initialized")+ }++ let window = UIWindow(windowScene: windowScene)+ self.window = window+ appDelegate.window = window++ // Under the scene lifecycle, URLs and user activities that launched the app arrive here+ // instead of in didFinishLaunchingWithOptions. Forward them so Linking.getInitialURL() works.+ var launchOptions = appDelegate.launchOptions ?? [:]+ if let url = connectionOptions.urlContexts.first?.url {+ launchOptions[.url] = url+ }+ if let activity = connectionOptions.userActivities.first {+ launchOptions[.userActivityDictionary] = ["UIApplicationLaunchOptionsUserActivityKey": activity]+ }++ factory.startReactNative(+ withModuleName: "main",+ in: window,+ launchOptions: launchOptions+ )+ }++ // MARK: - Linking API++ func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {+ for context in URLContexts {+ var options: [UIApplication.OpenURLOptionsKey: Any] = [+ .openInPlace: context.options.openInPlace+ ]+ if let sourceApplication = context.options.sourceApplication {+ options[.sourceApplication] = sourceApplication+ }+ if let annotation = context.options.annotation {+ options[.annotation] = annotation+ }+ _ = RCTLinkingManager.application(UIApplication.shared, open: context.url, options: options)+ }+ }++ // MARK: - Universal Links++ func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {+ _ = RCTLinkingManager.application(UIApplication.shared, continue: userActivity) { _ in }+ }+}