Skip to content

[ios]add flutter-ios-uiscene-root-vc-migration#191

Open
hellohuanlin wants to merge 2 commits into
flutter:mainfrom
hellohuanlin:ios_uiscene_root_vc_skill
Open

[ios]add flutter-ios-uiscene-root-vc-migration#191
hellohuanlin wants to merge 2 commits into
flutter:mainfrom
hellohuanlin:ios_uiscene_root_vc_skill

Conversation

@hellohuanlin

@hellohuanlin hellohuanlin commented Jul 21, 2026

Copy link
Copy Markdown

This skill migrates the legacy way to get the rootVC from UIApplication, which would be nil after UIScene adoption. The new approach is to get it from the new registrar.viewController API.

This skill has been battle tested for internal G3 plugins.

Just for sanity check, I have also tried it on a random public plugin flutter_barcode_scanner and confirmed it working too.

List which issues are fixed by this PR. You must list at least one issue.
NA

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new skill, flutter-ios-uiscene-root-vc-migration, to guide the migration of iOS Flutter plugins to the UIScene lifecycle by using registrar.viewController instead of legacy UIApplication delegate window access. The feedback identifies syntax errors in the Swift examples (using window?? instead of window?) and points out that the code snippets in the YAML configuration are missing essential initializers for both Swift and Objective-C, which would cause compilation failures.

Comment thread resources/flutter_skills.yaml
Comment thread skills/flutter-ios-uiscene-root-vc-migration/SKILL.md Outdated
Comment thread resources/flutter_skills.yaml
Comment thread resources/flutter_skills.yaml

# This is the configuration file for the skill generator.
# To generate skills, use the following command (from the `tool` directory):
# dart run skills generate-skill --config ../resources/flutter_skills.yaml --output ../skills

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cmd fails: Could not find an option named "--config".So I updated it.

@reidbaker
reidbaker requested review from jwren and removed request for reidbaker July 21, 2026 22:36
@reidbaker

Copy link
Copy Markdown
Contributor

replaced myself with @jwren (not sure who is responsible for the non dart_skills_lint parts of this codebase)


Identify usages of direct app-delegate window root view controller access. With the adoption of the `UIScene` lifecycle in iOS, `UIApplication.shared.delegate.window` evaluates to `nil`.

Locate and replace the following legacy patterns in the codebase:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to consider adding something that the patterns may not be exact.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my experiment, AI is pretty smart that it was able to detect similar patterns. For example, the flutter_barcode_scanner actually use a very different practice: https://github.com/AmolGangadhare/flutter_barcode_scanner/blob/55a1de73aed51194e58d2a85ddb987629f3adf7f/ios/Classes/SwiftFlutterBarcodeScannerPlugin.swift#L106


Follow this workflow to migrate a Flutter iOS plugin to support the `UIScene` lifecycle.

**Task Progress Checklist:**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a step to verify it's a plugin. We don't want to adding to non-plugin code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. Let me double check.

@vashworth

vashworth commented Jul 23, 2026

Copy link
Copy Markdown

This skill has been battle tested for internal G3 plugins.

Just for sanity check, I have also tried it on a random public plugin flutter_barcode_scanner and confirmed it working too.

I think you should test it more thoroughly against public plugins and apps. Like we don't want it to activate for apps, only for plugins. Can you verify it doesn't? Also test against plugins that don't need to be migrated, what does it do then?

model: models/gemini-3.1-pro-preview
last_modified: Tue, 21 Jul 2026 21:20:01 GMT
---
# Migrating Flutter iOS Plugins to UIScene

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This title is automatically added by AI. This is wrong

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it turns out that uiscene is automatically added because of this resource
- https://docs.flutter.dev/release/breaking-changes/uiscenedelegate

I changed it to registrar.viewController's API doc and UIScene references are gone: https://api.flutter.dev/ios-embedder/protocol_flutter_plugin_registrar-p.html#a732bebcd9fcfe9f9f74ea695848d7ea7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants