Skip to content

Conversation

@loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Apr 12, 2024

This migrates Flutter to use the @main attribute introduced in Swift 5.3. The @UIApplicationMain attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

  1. ad18797 - This updates the iOS app template and adds a migration to replace @UIApplicationMain uses with @main.
  2. 8ecbb2f - I ran flutter run on each Flutter iOS app in this repository to verify the app migrates and launches successfully.

Part of #143044

Pre-launch Checklist

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

@github-actions github-actions bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Apr 12, 2024
@loic-sharma loic-sharma force-pushed the uiapplicationmain_migration branch from 5cc9612 to ad18797 Compare April 15, 2024 17:20
@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Apr 15, 2024
import UIKit

@UIApplicationMain
@main
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't a Flutter application. I updated this by hand.

}

@UIApplicationMain
@main
Copy link
Member Author

Choose a reason for hiding this comment

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

This file contains significant edits from the starter app template. The migration is flexible enough to be able to update this correctly.

@loic-sharma loic-sharma marked this pull request as ready for review April 15, 2024 18:31
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Minor nits, LGTM! Thank you for doing this!

@jmagman
Copy link
Member

jmagman commented Apr 15, 2024

"Addresses #143044" if you make this "Fixes #143044" GitHub will link them and close the issue when this is merged.

@vashworth
Copy link
Contributor

"Addresses #143044" if you make this "Fixes #143044" GitHub will link them and close the issue when this is merged.

@loic-sharma Did you happen to check if NSApplicationMain (the macOS version of this) was also deprecated?

I'm not sure if we want to mark the issue as fixed since it refers to both the iOS and macOS version. If we want to handle them separately, can you file a separate issue to address the macOS one?

@hellohuanlin
Copy link
Contributor

How do I trigger this migration for existing projects? Do I run a migration command? Or do I simply do flutter clean and then regenerate these files?

@jmagman
Copy link
Member

jmagman commented Apr 16, 2024

How do I trigger this migration for existing projects? Do I run a migration command? Or do I simply do flutter clean and then regenerate these files?

The migrations run when the app compiles, so every flutter run will do it. It doesn't need to be regenerated, the migration edits the existing file.

@loic-sharma
Copy link
Member Author

loic-sharma commented Apr 16, 2024

@vashworth Good point, I'll update the macOS template in a follow-up pull request using the same issue. I'll keep the issue open until then!

EDIT: macOS pull request is here: #146848

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 16, 2024
@auto-submit auto-submit bot merged commit 194fefa into flutter:master Apr 16, 2024
@loic-sharma loic-sharma deleted the uiapplicationmain_migration branch April 16, 2024 22:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2024
auto-submit bot pushed a commit that referenced this pull request Apr 18, 2024
This migrates Flutter to use the `@main` attribute introduced in Swift 5.3. The `@NSApplicationMain` attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

1. a508d3e - This updates the macOS app template and adds a migration to replace `@NSApplicationMain` uses with `@main`. 
2. f434827 - I ran `flutter run -d macos` on each Flutter macOS app in this repository to verify the app migrates and launches successfully.

Follow-up to #146707
Fixes #143044
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 18, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 18, 2024
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
This migrates Flutter to use the `@main` attribute introduced in Swift 5.3. The `@UIApplicationMain` attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

1. flutter@ad18797 - This updates the iOS app template and adds a migration to replace `@UIApplicationMain` uses with `@main`. 
2. flutter@8ecbb2f - I ran `flutter run` on each Flutter iOS app in this repository to verify the app migrates and launches successfully.

Part of flutter#143044
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
This migrates Flutter to use the `@main` attribute introduced in Swift 5.3. The `@NSApplicationMain` attribute is deprecated and will be removed in Swift 6. See: https://github.com/apple/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md

This change is split into two commits:

1. flutter@a508d3e - This updates the macOS app template and adds a migration to replace `@NSApplicationMain` uses with `@main`. 
2. flutter@f434827 - I ran `flutter run -d macos` on each Flutter macOS app in this repository to verify the app migrates and launches successfully.

Follow-up to flutter#146707
Fixes flutter#143044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants