Skip to content

Commit 80efc5b

Browse files
vashworthsfshaza2gemini-code-assist[bot]
authored
Add additional instructions to UIScene Migration (#12592)
_Description of what this PR is changing or adding, and why:_ Adds instructions on how to add a SceneDelegate and how to use auto-migrator _Issues fixed by this PR (if any):_ _PRs or commits this PR depends on (if any):_ ## Presubmit checklist - [x] If you are unwilling, or unable, to sign the CLA, even for a _tiny_, one-word PR, please file an issue instead of a PR. - [x] If this PR is not meant to land until a future stable release, mark it as draft with an explanation. - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style)—for example, it doesn't use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person pronouns). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Shams Zakhour <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 6dd00ad commit 80efc5b

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed
30.2 KB
Loading

src/content/release/breaking-changes/uiscenedelegate.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,28 @@ UIKit won't call AppDelegate methods related to UI state.
4747

4848
## Migration guide for Flutter apps
4949

50-
The Flutter CLI will automatically migrate your app when you run `flutter run`
51-
or `flutter build ios` if your AppDelegate has not been customized. Otherwise,
52-
you must migrate manually.
50+
### Auto-Migrate (Experimental)
51+
52+
The Flutter CLI can automatically migrate your app if your AppDelegate has not
53+
been customized.
54+
55+
1. Enable UIScene Migration Feature
56+
57+
```console
58+
flutter config --enable-uiscene-migration
59+
```
60+
61+
2. Build or run your app
62+
63+
```console
64+
flutter run
65+
or
66+
flutter build ios
67+
```
68+
69+
If the migration succeeds, you will see a log that says "Finished migration to
70+
UIScene lifecycle". Otherwise, it warns you to migrate manually using the
71+
included instructions. If the migration succeeds, no further action is required!
5372

5473
### Migrate AppDelegate
5574

@@ -206,6 +225,51 @@ As XML:
206225
</dict>
207226
```
208227

228+
### Create a SceneDelegate (Optional)
229+
230+
If you need access to the `SceneDelegate`, you can create one by
231+
subclassing `FlutterSceneDelegate`.
232+
233+
1. Open your app in Xcode
234+
2. Right click the **Runner** folder and select **New Empty File**
235+
236+
![New Empty File option in
237+
Xcode](/assets/images/docs/breaking-changes/uiscene-new-file.png)
238+
239+
For Swift projects, create a `SceneDelegate.swift`:
240+
241+
```swift title=my_app/ios/Runner/SceneDelegate.swift
242+
import Flutter
243+
import UIKit
244+
245+
class SceneDelegate: FlutterSceneDelegate {
246+
247+
}
248+
```
249+
250+
For Objective-C projects, create a `SceneDelegate.h` and `SceneDelegate.m`:
251+
252+
```objc title=my_app/ios/Runner/SceneDelegate.h
253+
#import <Flutter/Flutter.h>
254+
#import <UIKit/UIKit.h>
255+
256+
@interface SceneDelegate : FlutterSceneDelegate
257+
258+
@end
259+
```
260+
261+
```objc title=my_app/ios/Runner/SceneDelegate.m
262+
#import "SceneDelegate.h"
263+
264+
@implementation SceneDelegate
265+
266+
@end
267+
```
268+
269+
3. Change the "Delegate Class Name" (`UISceneDelegateClassName`) in the
270+
Info.plist from `FlutterSceneDelegate` to
271+
`$(PRODUCT_MODULE_NAME).SceneDelegate`.
272+
209273
## Migration guide for Flutter plugins
210274

211275
Not all plugins use lifecycle events. If your plugin does, though, you will

0 commit comments

Comments
 (0)