Skip to content

Commit 4cbc760

Browse files
robingenzclaude
andcommitted
chore(ios): adopt UIScene lifecycle for Capacitor 8.5
Required to build with Xcode 27. See https://capacitorjs.com/docs/updating/8-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dbc8d91 commit 4cbc760

4 files changed

Lines changed: 54 additions & 14 deletions

File tree

‎ios/App/App.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; };
1111
50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; };
1212
504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; };
13+
9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9582B6822FE993A50072D4E8 /* SceneDelegate.swift */; };
1314
504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; };
1415
504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; };
1516
504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; };
@@ -22,6 +23,7 @@
2223
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
2324
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
2425
504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
26+
9582B6822FE993A50072D4E8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
2527
504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2628
504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2729
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -77,6 +79,7 @@
7779
7CFB9646282464D200384199 /* App.entitlements */,
7880
50379B222058CBB4000EE86E /* capacitor.config.json */,
7981
504EC3071FED79650016851F /* AppDelegate.swift */,
82+
9582B6822FE993A50072D4E8 /* SceneDelegate.swift */,
8083
504EC30B1FED79650016851F /* Main.storyboard */,
8184
504EC30E1FED79650016851F /* Assets.xcassets */,
8285
504EC3101FED79650016851F /* LaunchScreen.storyboard */,
@@ -210,6 +213,7 @@
210213
buildActionMask = 2147483647;
211214
files = (
212215
504EC3081FED79650016851F /* AppDelegate.swift in Sources */,
216+
9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */,
213217
);
214218
runOnlyForDeploymentPostprocessing = 0;
215219
};

‎ios/App/App/AppDelegate.swift‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3333
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
3434
}
3535

36-
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
37-
// Called when the app was launched with a url. Feel free to add additional processing here,
38-
// but if you want the App API to support tracking app url opens, make sure to keep this call
39-
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
36+
func application(_ application: UIApplication,
37+
configurationForConnecting connectingSceneSession: UISceneSession,
38+
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
39+
let config = UISceneConfiguration(name: "Default Configuration",
40+
sessionRole: connectingSceneSession.role)
41+
config.delegateClass = SceneDelegate.self
42+
return config
4043
}
41-
42-
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
43-
// Called when the app was launched with an activity, including Universal Links.
44-
// Feel free to add additional processing here, but if you want the App API to support
45-
// tracking app url opens, make sure to keep this call
46-
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
47-
}
48-
49-
5044
}
51-

‎ios/App/App/Info.plist‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@
2626
<string>The app enables the reading and writing of various NFC tags.</string>
2727
<key>UILaunchStoryboardName</key>
2828
<string>LaunchScreen</string>
29+
<key>UIApplicationSceneManifest</key>
30+
<dict>
31+
<key>UIApplicationSupportsMultipleScenes</key>
32+
<false/>
33+
<key>UISceneConfigurations</key>
34+
<dict>
35+
<key>UIWindowSceneSessionRoleApplication</key>
36+
<array>
37+
<dict>
38+
<key>UISceneConfigurationName</key>
39+
<string>Default Configuration</string>
40+
<key>UISceneDelegateClassName</key>
41+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
42+
<key>UISceneStoryboardFile</key>
43+
<string>Main</string>
44+
</dict>
45+
</array>
46+
</dict>
47+
</dict>
2948
<key>UIMainStoryboardFile</key>
3049
<string>Main</string>
3150
<key>UIRequiredDeviceCapabilities</key>

‎ios/App/App/SceneDelegate.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import UIKit
2+
import Capacitor
3+
4+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
5+
var window: UIWindow?
6+
7+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
8+
guard let windowScene = scene as? UIWindowScene else { return }
9+
10+
window = UIWindow(windowScene: windowScene)
11+
window?.rootViewController = CAPBridgeViewController()
12+
window?.makeKeyAndVisible()
13+
14+
SceneDelegateProxy.shared.scene(scene, willConnectTo: session, options: connectionOptions)
15+
}
16+
17+
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
18+
SceneDelegateProxy.shared.scene(scene, openURLContexts: URLContexts)
19+
}
20+
21+
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
22+
SceneDelegateProxy.shared.scene(scene, continue: userActivity)
23+
}
24+
}

0 commit comments

Comments
 (0)