Skip to content

bug(ios): 8.5 template creates the bridge view controller twice (storyboard scene key + SceneDelegate) #8723

Open

Description

@jacobg

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.plist sets UISceneStoryboardFile = Main in the scene manifest, and still sets UIMainStoryboardFile = Main. The initial view controller of Main.storyboard is CAPBridgeViewController.
  • SceneDelegate.scene(_:willConnectTo:options:) creates its own UIWindow and a new CAPBridgeViewController() 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 UISceneStoryboardFile from the scene configuration in Info.plist.
  • Remove UIMainStoryboardFile from Info.plist. It is ignored when a scene manifest is present.
  • Optionally remove Main.storyboard from the template, and update the 8.5 guide and cap migrate to 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:

  1. In the generated iOS project, create class AppViewController: CAPBridgeViewController that logs in init(coder:), init(nibName:bundle:), capacitorDidLoad() and deinit.
  2. Set it as the custom class of the initial view controller in Main.storyboard, and use it in SceneDelegate (window?.rootViewController = AppViewController()), as the guide suggests for custom subclasses.
  3. Launch the app and watch the log: there are two initializers and one deinit per launch.
  4. With UISceneStoryboardFile and UIMainStoryboardFile removed from Info.plist, the app still launches normally with one bridge, created by the SceneDelegate.

Activity

  1. ayannabansal commented on Nov 24, 2026

    @ayannabansal

    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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions