-
Notifications
You must be signed in to change notification settings - Fork 592
Description
iOS apps must adopt the UIScene lifecycle in iOS 27:
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate
Apps that have adopted UIScene can no longer access the rootViewController via [UIApplication sharedApplication].delegate.window, [UIApplication sharedApplication].keyWindow.rootViewController, etc. The former is how open_file does it, but when I run my app (which has adopted UIScene) in a debugger I find that viewController here does indeed end up nil:
open_file/open_file_ios/ios/open_file_ios/Sources/open_file_ios/OpenFilePlugin.m
Lines 19 to 20 in bfa5065
| UIViewController *viewController = | |
| [UIApplication sharedApplication].delegate.window.rootViewController; |
This results in calls to open_file to fail.
The migration document I linked to above talks about adopting the FlutterSceneLifeCycleDelegate and working with UISceneDelegate calls. I don't know enough about UIScene to know how to do it that way; what I have seen in other plugins like share_plus is a brute force search through all windows in all scenes to find the key window and its rootViewController:
https://github.com/fluttercommunity/plus_plugins/pull/1157/files
I have copied that approach in my branch of file_picker_writable and it has worked fine.