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

Đang mở
#8,723 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
swift, typescript
Lĩnh vực
backend, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
17.1k
Fork
1.3k
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
32

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ionic-team/capacitor

Tất cả issue của ionic-team/capacitor

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.