open_file icon indicating copy to clipboard operation
open_file copied to clipboard

Need to migrate for UISceneDelegate adoption

Open amake opened this issue 1 month ago • 0 comments

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: https://github.com/crazecoder/open_file/blob/bfa5065983867cc24d9678b7794a965040a65241/open_file_ios/ios/open_file_ios/Sources/open_file_ios/OpenFilePlugin.m#L19-L20

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.

amake avatar Nov 20 '25 14:11 amake