这是indexloc提供的服务,不要输入任何密码
Skip to content

Add deprecation warning for "flutter create --ios-language" #155867

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

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/flutter_tools/lib/src/commands/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ class CreateCommand extends CreateBase {
'template: the language will always be C or C++.',
exitCode: 2,
);
} else if (argResults!.wasParsed('ios-language')) {
globals.printWarning(
'The "ios-language" option is deprecated and will be removed in a future Flutter release.');
if (stringArg('ios-language') == 'objc') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want this call to action for all cases, or just plugins? I was envisioning just the latter, since the usage is higher there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I figured I would do it for all in case there's some super compelling reason for the app template as well that I haven't thought of. This should be a rare warning.

I did remove the module check since no one should be using the flag for that template anyway, may as well warn them it's being removed if they are using it for some weird reason.

globals.printWarning(
'Please comment in https://github.com/flutter/flutter/issues/148586 describing your use-case for using Objective-C instead of Swift.');
}
}

final String organization = await getOrganization();
Expand Down
5 changes: 3 additions & 2 deletions packages/flutter_tools/lib/src/commands/create_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ abstract class CreateBase extends FlutterCommand {
abbr: 'i',
defaultsTo: 'swift',
allowed: <String>['objc', 'swift'],
help: 'The language to use for iOS-specific code, either Objective-C (legacy) or Swift (recommended).'
help: '(deprecated) The language to use for iOS-specific code, either Swift (recommended) or Objective-C (legacy).',
hide: !verboseHelp,
);
argParser.addOption(
'android-language',
abbr: 'a',
defaultsTo: 'kotlin',
allowed: <String>['java', 'kotlin'],
help: 'The language to use for Android-specific code, either Java (legacy) or Kotlin (recommended).',
help: 'The language to use for Android-specific code, either Kotlin (recommended) or Java (legacy).',
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know enough abt this area but does this section need hide: !verboseHelp, too?

Copy link
Member Author

Choose a reason for hiding this comment

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

--android-language isn't being deprecated, and not in this PR. I just changed the order to match the iOS one, and because putting the recommended one first is a good suggestion.

);
argParser.addFlag(
'skip-name-checks',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,36 @@ void main() {
expect(displayName, 'My Project');
});

testUsingContext('should not show --ios-language deprecation warning issue for Swift', () async {
Cache.flutterRoot = '../..';

final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);

await runner.run(<String>['create', '--no-pub', '--ios-language=swift', projectDir.path]);
expect(logger.warningText, contains('The "ios-language" option is deprecated and will be removed in a future Flutter release.'));
expect(logger.warningText, isNot(contains('https://github.com/flutter/flutter/issues/148586')));

}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
Logger: () => logger,
});

testUsingContext('should show --ios-language deprecation warning issue for Objective-C', () async {
Cache.flutterRoot = '../..';

final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);

await runner.run(<String>['create', '--no-pub', '--ios-language=objc', projectDir.path]);
expect(logger.warningText, contains('The "ios-language" option is deprecated and will be removed in a future Flutter release.'));
expect(logger.warningText, contains('https://github.com/flutter/flutter/issues/148586'));

}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
Logger: () => logger,
});

testUsingContext('has correct content and formatting with macOS app template', () async {
Cache.flutterRoot = '../..';

Expand Down