Skip to content

Need to migrate for UISceneDelegate adoption #340

@amake

Description

@amake

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions