Repository navigation
Description
Capacitor Version
@capacitor/cli 8.5.3, @capacitor/ios 8.5.x (iOS SPM template)
Other API Details
Xcode 27.2, iOS 26.5 Simulator
Platforms Affected
- iOS
- Android
- Web
Current Behavior
The 8.5 iOS template (and the 8.5 update guide) configures the window in two ways at once:
Info.plistsetsUISceneStoryboardFile = Mainin the scene manifest, and still setsUIMainStoryboardFile = Main. The initial view controller ofMain.storyboardisCAPBridgeViewController.SceneDelegate.scene(_:willConnectTo:options:)creates its ownUIWindowand a newCAPBridgeViewController()in code.
Because the scene manifest names a storyboard, UIKit instantiates the storyboard's initial view controller on every launch before calling scene(_:willConnectTo:). The SceneDelegate then replaces the window, and the storyboard's controller is deallocated without loading its view.
I confirmed this by logging in a CAPBridgeViewController subclass. On each launch, both a normal launch and a background launch from a silent push, there is one init(coder:) (storyboard), one init(nibName:bundle:) (SceneDelegate), one capacitorDidLoad(), and one deinit.
In my testing the extra controller never loads a bridge, so this is redundant work, not a confirmed functional bug. I'm raising it because the setup is ambiguous: two code paths can create a CAPBridgeViewController, and the guide says Main.storyboard "no longer provides" the window or root view controller.
For context, we're investigating rare production cases on iOS where two bridges (two web app instances) appeared to run at once in a Capacitor 8.5 app, which showed up as SQLite database is locked errors. I could not tie that to this template setup, and I'm not claiming it is the cause.
Expected Behavior
The window and root view controller are created in one place. Since the SceneDelegate builds them in code, I'd propose the template drops the storyboard references:
- Remove
UISceneStoryboardFilefrom the scene configuration inInfo.plist. - Remove
UIMainStoryboardFilefromInfo.plist. It is ignored when a scene manifest is present. - Optionally remove
Main.storyboardfrom the template, and update the 8.5 guide andcap migrateto match.
The other option is to keep the storyboard and have the SceneDelegate use the window UIKit creates, without building its own. Then a custom CAPBridgeViewController subclass would be set in the storyboard, as before 8.5.
Is dropping the storyboard keys what you'd recommend for apps that have migrated? Or is there a reason the template keeps both?
Project Reproduction
Any new app from the @capacitor/cli 8.5.3 iOS SPM template (npx cap add ios). No custom code is needed except the logging below.
Additional Information
Steps to observe:
- In the generated iOS project, create
class AppViewController: CAPBridgeViewControllerthat logs ininit(coder:),init(nibName:bundle:),capacitorDidLoad()anddeinit. - Set it as the custom class of the initial view controller in
Main.storyboard, and use it inSceneDelegate(window?.rootViewController = AppViewController()), as the guide suggests for custom subclasses. - Launch the app and watch the log: there are two initializers and one
deinitper launch. - With
UISceneStoryboardFileandUIMainStoryboardFileremoved fromInfo.plist, the app still launches normally with one bridge, created by the SceneDelegate.
Activity
ayannabansal commentedon Nov 24, 2026
I can reproduce this on a fresh 8.6.2 SPM project (Xcode 26.1.1, iPhone 17 simulator, iOS 26.1).
I added a CAPBridgeViewController subclass that logs when it's created and destroyed, and set it in both Main.storyboard and SceneDelegate. On every launch I get init(coder:) from the storyboard, then init(nibName:bundle:) from the SceneDelegate, then capacitorDidLoad on the second one, and a deinit of the first.
After removing UISceneStoryboardFile and UIMainStoryboardFile from Info.plist there's only the SceneDelegate one, and the app loads fine.
Two things I noticed while looking at this:
I only tried normal launches on the simulator, not a device or a background launch.
If dropping the two keys from the 8.x templates is the fix you'd want, I can send a PR against 8.x for both the SPM and CocoaPods templates.