Conversation
…cle)
The modern Flutter iOS template uses the UIScene lifecycle, so
UIApplication.shared.delegate.window is nil and the plugin's init()
fatalErrors ('rootViewController is not type FlutterViewController'),
crashing the host app at launch during plugin registration.
Resolve the window from UIApplication.connectedScenes when the app
delegate has none, and skip the redundant init-time channel wiring
(also done in register(with:)) instead of crashing.
Owner
|
Hi @vingulati, thank you for your contribution though this has already been fixed by PR #320 merged yesterday. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the modern Flutter iOS template (Flutter ≥ 3.35, which uses the UIScene lifecycle — a
SceneDelegateextendingFlutterSceneDelegate+ aUIApplicationSceneManifest),UIApplication.shared.delegate.windowis alwaysnilbecause the window is owned by the scene, not the app delegate.SwiftTwilioVoicePlugin.init()does:Because
appDelegate.windowisnil, thisfatalErrors during plugin registration — crashing the entire host app at launch, before any Dart runs. Stack trace bottoms out atSwiftTwilioVoicePlugin.init()→register(with:)→GeneratedPluginRegistrant→didInitializeImplicitFlutterEngine.Fix
Resolve the window from
UIApplication.shared.connectedSceneswhen the app delegate has no window, and — since the method/event channels are also wired inregister(with:)— degrade gracefully (return) instead offatalErrorif the root view controller isn't attached yet during registration.No behavior change for classic (non-scene) apps:
appDelegate.windowis used first when present.Testing
Reproduced the launch crash on a Flutter 3.44.7 app using the UIScene template (iOS 26 simulator). With this change the host app launches normally and the plugin's channels work. Verified against tag
0.3.2+2.🤖 Generated with Claude Code