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

The Objective-C  `flutter create --ios-language objc` template will be removed in https://github.com/flutter/flutter/issues/148586.

Add a deprecation warning when this flag is passed.  Add an additional warning when Objective-C is specified requesting the user's use-case.

Do not show the warning when creating the module, as Swift is not supported for it yet https://github.com/flutter/flutter/issues/23955

![Screenshot 2024-09-27 at 8 54 16 PM](https://github.com/user-attachments/assets/112be47f-a5bd-4f57-9a9d-c96c7bbc8ac3)

Part of https://github.com/flutter/flutter/issues/148586
This commit is contained in:
Jenn Magder 2024-10-02 09:13:25 -07:00 committed by GitHub
parent ff7e5f3d73
commit 22247cd55c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 2 deletions

View File

@ -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') {
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();

View File

@ -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).',
);
argParser.addFlag(
'skip-name-checks',

View File

@ -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 = '../..';