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  Part of https://github.com/flutter/flutter/issues/148586
This commit is contained in:
parent
ff7e5f3d73
commit
22247cd55c
@ -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();
|
||||
|
@ -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',
|
||||
|
@ -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 = '../..';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user