(Draft) Update iOS snippets to reflect UISceneDelegate adoption#13305
(Draft) Update iOS snippets to reflect UISceneDelegate adoption#13305johnpryan wants to merge 2 commits intoflutter:mainfrom
Conversation
|
Visit the preview URL for this PR (updated for commit 7bdc9a8): https://flutter-docs-prod--pr13305-migrate-docs-to-uiscene-iiubeubj.web.app |
sfshaza2
left a comment
There was a problem hiding this comment.
This looks great, @johnpryan! I know it's a draft, but I will approve. Let me know if it needs further attention.
There was a problem hiding this comment.
Code Review
This pull request updates iOS documentation to reflect UIScene support as the default and transitions platform integration examples to use didInitializeImplicitFlutterEngine:. Feedback includes correcting a version typo, updating documentation links to UISceneDelegate methods, adopting idiomatic Swift naming conventions, and fixing a missing header import in an Objective-C snippet.
| As of Flutter 3.41, `UIScene` support is the default for iOS apps. | ||
| When using `FlutterAppDelegate`, you should also ensure that your app | ||
| uses `FlutterSceneDelegate` (or a subclass) to receive scene lifecycle | ||
| events, such as [`openURL`][] and [`continueUserActivity`][]. |
There was a problem hiding this comment.
There was a problem hiding this comment.
Gemini is correct. The UIScene methods are:
https://developer.apple.com/documentation/uikit/uiscenedelegate/scene(_:continue:)
https://developer.apple.com/documentation/uikit/uiscenedelegate/scene(_:openurlcontexts:)
| @@ -163,7 +163,7 @@ Finally, register the platform view. | |||
| This can be done in an app or a plugin. | |||
|
|
|||
| For app registration, | |||
| modify the App's `AppDelegate.swift`: | |||
| implement the `didInitializeImplicitFlutterEngine:` method in the App's `AppDelegate.swift`: | |||
There was a problem hiding this comment.
In the Swift section, it is more idiomatic to use Swift method naming conventions instead of the Objective-C selector style.
| implement the `didInitializeImplicitFlutterEngine:` method in the App's `AppDelegate.swift`: | |
| implement the `didInitializeImplicitFlutterEngine(_:)` method in the App's `AppDelegate.swift`: |
| @@ -608,7 +608,7 @@ Add support for Swift in the standard template setup that uses Objective-C: | |||
| 1. Open the file `AppDelegate.swift` located under **Runner > Runner** | |||
| in the Project navigator. | |||
|
|
|||
| Override the `application:didFinishLaunchingWithOptions:` function and create | |||
| Implement the `didInitializeImplicitFlutterEngine:` method and create | |||
There was a problem hiding this comment.
| #import <Flutter/Flutter.h> | ||
| #import "GeneratedPluginRegistrant.h" | ||
|
|
||
| @interface AppDelegate () <FlutterImplicitEngineDelegate> | ||
| @end |
There was a problem hiding this comment.
The Objective-C snippet for AppDelegate.m is missing the import for AppDelegate.h. This will cause a compilation error as the compiler won't recognize the AppDelegate class when declaring the category.
| #import <Flutter/Flutter.h> | |
| #import "GeneratedPluginRegistrant.h" | |
| @interface AppDelegate () <FlutterImplicitEngineDelegate> | |
| @end | |
| #import "AppDelegate.h" | |
| #import <Flutter/Flutter.h> | |
| #import "GeneratedPluginRegistrant.h" | |
| @interface AppDelegate () <FlutterImplicitEngineDelegate> | |
| @end |
| ) | ||
| configuration.delegateClass = FlutterSceneDelegate.self | ||
| return configuration | ||
| } |
There was a problem hiding this comment.
Hmm, I'm not sure where this is from, but I don't think this is what we want to recommend.
Add-to-App users need to update their SceneDelegate (or create one and add to Info.plist if they don't already have one) to subclass the FlutterSceneDelegate and if they can't, then to use the FlutterSceneLifeCycleProvider
See UIScene docs:
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate#migration-guide-for-adding-flutter-to-existing-app-add-to-app
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate#migrate-info-plist
https://docs.flutter.dev/release/breaking-changes/uiscenedelegate#migrate-info-plist
| As of Flutter 3.41, `UIScene` support is the default for iOS apps. | ||
| When using `FlutterAppDelegate`, you should also ensure that your app | ||
| uses `FlutterSceneDelegate` (or a subclass) to receive scene lifecycle | ||
| events, such as [`openURL`][] and [`continueUserActivity`][]. |
There was a problem hiding this comment.
Gemini is correct. The UIScene methods are:
https://developer.apple.com/documentation/uikit/uiscenedelegate/scene(_:continue:)
https://developer.apple.com/documentation/uikit/uiscenedelegate/scene(_:openurlcontexts:)
- Update platform-channels.md to use didInitializeImplicitFlutterEngine. - Update platform-views.md to use didInitializeImplicitFlutterEngine and add protocol conformance. - Update add-flutter-screen.md to include configurationForConnecting in AppDelegate. Fixes flutter#13087 Fixes flutter#13086 Fixes flutter#13274
f33ea89 to
7bdc9a8
Compare
Description of what this PR is changing or adding, and why:
This updates iOS code snippets to conform to the UIScene lifecycle migration.
Issues fixed by this PR (if any):
Fixes #13087
Fixes #13086
Fixes #13274
PRs or commits this PR depends on (if any):
None.
Presubmit checklist
of 80 characters or fewer.