-
Notifications
You must be signed in to change notification settings - Fork 3.5k
(Draft) Update iOS snippets to reflect UISceneDelegate adoption #13305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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`: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Swift section, it is more idiomatic to use Swift method naming conventions instead of the Objective-C selector style.
Suggested change
|
||||||
|
|
||||||
| ```swift | ||||||
| import Flutter | ||||||
|
|
@@ -286,13 +286,16 @@ Finally, register the platform view. | |||||
| This can be done in an app or a plugin. | ||||||
|
|
||||||
| For app registration, | ||||||
| modify the App's `AppDelegate.m`: | ||||||
| implement the `didInitializeImplicitFlutterEngine:` method in the App's `AppDelegate.m`: | ||||||
|
|
||||||
| ```objc | ||||||
| #import "AppDelegate.h" | ||||||
| #import "FLNativeView.h" | ||||||
| #import "GeneratedPluginRegistrant.h" | ||||||
|
|
||||||
| @interface AppDelegate () <FlutterImplicitEngineDelegate> | ||||||
| @end | ||||||
|
|
||||||
| @implementation AppDelegate | ||||||
|
|
||||||
| - (void)didInitializeImplicitFlutterEngine:(NSObject<FlutterImplicitEngineBridge>*)engineBridge { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||
| a `FlutterMethodChannel` tied to the channel name | ||||||||||||||||||||||||
| `samples.flutter.dev/battery`: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -696,8 +696,8 @@ Start by opening the iOS host portion of the Flutter app in Xcode: | |||||||||||||||||||||||
| 1. Open the file `AppDelegate.m`, located under **Runner > Runner** | ||||||||||||||||||||||||
| in the Project navigator. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Create a `FlutterMethodChannel` and add a handler inside the `application | ||||||||||||||||||||||||
| didFinishLaunchingWithOptions:` method. | ||||||||||||||||||||||||
| Create a `FlutterMethodChannel` and add a handler inside the | ||||||||||||||||||||||||
| `didInitializeImplicitFlutterEngine:` method. | ||||||||||||||||||||||||
| Make sure to use the same channel name | ||||||||||||||||||||||||
| as was used on the Flutter client side. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -712,6 +712,9 @@ create your `FlutterMethodChannel` in the `didInitializeImplicitFlutterEngine` m | |||||||||||||||||||||||
| #import <Flutter/Flutter.h> | ||||||||||||||||||||||||
| #import "GeneratedPluginRegistrant.h" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @interface AppDelegate () <FlutterImplicitEngineDelegate> | ||||||||||||||||||||||||
| @end | ||||||||||||||||||||||||
|
Comment on lines
712
to
+716
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Objective-C snippet for
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @implementation AppDelegate | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - (void)didInitializeImplicitFlutterEngine:(NSObject<FlutterImplicitEngineBridge>*)engineBridge { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 theFlutterSceneDelegateand if they can't, then to use theFlutterSceneLifeCycleProviderSee 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