Skip to content

Commit 22247cd

Browse files
authored
Add deprecation warning for "flutter create --ios-language" (#155867)
The Objective-C `flutter create --ios-language objc` template will be removed in flutter/flutter#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 flutter/flutter#23955 ![Screenshot 2024-09-27 at 8 54 16�PM](https://github.com/user-attachments/assets/112be47f-a5bd-4f57-9a9d-c96c7bbc8ac3) Part of flutter/flutter#148586
1 parent ff7e5f3 commit 22247cd

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

packages/flutter_tools/lib/src/commands/create.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ class CreateCommand extends CreateBase {
258258
'template: the language will always be C or C++.',
259259
exitCode: 2,
260260
);
261+
} else if (argResults!.wasParsed('ios-language')) {
262+
globals.printWarning(
263+
'The "ios-language" option is deprecated and will be removed in a future Flutter release.');
264+
if (stringArg('ios-language') == 'objc') {
265+
globals.printWarning(
266+
'Please comment in https://github.com/flutter/flutter/issues/148586 describing your use-case for using Objective-C instead of Swift.');
267+
}
261268
}
262269

263270
final String organization = await getOrganization();

packages/flutter_tools/lib/src/commands/create_base.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,15 @@ abstract class CreateBase extends FlutterCommand {
100100
abbr: 'i',
101101
defaultsTo: 'swift',
102102
allowed: <String>['objc', 'swift'],
103-
help: 'The language to use for iOS-specific code, either Objective-C (legacy) or Swift (recommended).'
103+
help: '(deprecated) The language to use for iOS-specific code, either Swift (recommended) or Objective-C (legacy).',
104+
hide: !verboseHelp,
104105
);
105106
argParser.addOption(
106107
'android-language',
107108
abbr: 'a',
108109
defaultsTo: 'kotlin',
109110
allowed: <String>['java', 'kotlin'],
110-
help: 'The language to use for Android-specific code, either Java (legacy) or Kotlin (recommended).',
111+
help: 'The language to use for Android-specific code, either Kotlin (recommended) or Java (legacy).',
111112
);
112113
argParser.addFlag(
113114
'skip-name-checks',

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,36 @@ void main() {
16861686
expect(displayName, 'My Project');
16871687
});
16881688

1689+
testUsingContext('should not show --ios-language deprecation warning issue for Swift', () async {
1690+
Cache.flutterRoot = '../..';
1691+
1692+
final CreateCommand command = CreateCommand();
1693+
final CommandRunner<void> runner = createTestCommandRunner(command);
1694+
1695+
await runner.run(<String>['create', '--no-pub', '--ios-language=swift', projectDir.path]);
1696+
expect(logger.warningText, contains('The "ios-language" option is deprecated and will be removed in a future Flutter release.'));
1697+
expect(logger.warningText, isNot(contains('https://github.com/flutter/flutter/issues/148586')));
1698+
1699+
}, overrides: <Type, Generator>{
1700+
FeatureFlags: () => TestFeatureFlags(),
1701+
Logger: () => logger,
1702+
});
1703+
1704+
testUsingContext('should show --ios-language deprecation warning issue for Objective-C', () async {
1705+
Cache.flutterRoot = '../..';
1706+
1707+
final CreateCommand command = CreateCommand();
1708+
final CommandRunner<void> runner = createTestCommandRunner(command);
1709+
1710+
await runner.run(<String>['create', '--no-pub', '--ios-language=objc', projectDir.path]);
1711+
expect(logger.warningText, contains('The "ios-language" option is deprecated and will be removed in a future Flutter release.'));
1712+
expect(logger.warningText, contains('https://github.com/flutter/flutter/issues/148586'));
1713+
1714+
}, overrides: <Type, Generator>{
1715+
FeatureFlags: () => TestFeatureFlags(),
1716+
Logger: () => logger,
1717+
});
1718+
16891719
testUsingContext('has correct content and formatting with macOS app template', () async {
16901720
Cache.flutterRoot = '../..';
16911721

0 commit comments

Comments
 (0)