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

オープン
#8,723 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
swift, typescript
領域
backend, mobile

調査の方向性

Start with the generated iOS SPM template’s Info.plist, SceneDelegate, and Main.storyboard, then compare them with the 8.5 update guide and cap migrate behavior. Check how the scene manifest and storyboard settings interact with the SceneDelegate-created window. Done means the template and migration guidance use one consistent setup and a generated app launches with one bridge.

索引モデルが issue の本文から書いたものです。

説明

triage
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.
主要言語
TypeScript
スター
17.1k
フォーク
1.3k
平均マージ
2日 1時間
マージ済み PR(30日)
32

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ionic-team/capacitor のほかの issue

ionic-team/capacitor の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。