[hotfix] flutter create -t plugin remove no-op iOS folder and set sdk min to 1.20.0 (#62990)
This is a cherry-pick of 004f90f8fd8a8fb93d386d55364707ef1e517948, 2459f5c513e26f7bc60d68d8e58972d37bbd6e58
and c9cd825fcae2fb7ead6343eb4eb7fa98e27f0d0f
diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart
index b3f8f78..eacdacb 100644
--- a/packages/flutter_tools/lib/src/template.dart
+++ b/packages/flutter_tools/lib/src/template.dart
@@ -129,9 +129,10 @@
return null;
}
- // TODO(cyanglaz): do not add iOS folder by default when 1.20.0 is released.
- // Also need to update the flutter SDK min constraint in the pubspec.yaml to 1.20.0.
- // https://github.com/flutter/flutter/issues/59787
+ final bool ios = context['ios'] as bool;
+ if (relativeDestinationPath.contains('ios') && !ios) {
+ return null;
+ }
// Only build a web project if explicitly asked.
final bool web = context['web'] as bool;
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart
index e798a36..b908133 100644
--- a/packages/flutter_tools/lib/src/version.dart
+++ b/packages/flutter_tools/lib/src/version.dart
@@ -776,7 +776,7 @@
// recent tag and number of commits past.
return parse(
_runGit(
- 'git describe --match *.*.*-*.*.pre --first-parent --long --tags',
+ 'git describe --match *.*.* --first-parent --long --tags',
processUtils,
workingDirectory,
)
@@ -851,7 +851,7 @@
if (devPatch != null && devVersion != null) {
return '$x.$y.$z-${devVersion + 1}.0.pre.$commits';
}
- return '$x.$y.${z + 1}.pre.$commits';
+ return '$x.$y.${z + 1}-0.0.pre.$commits';
}
}
diff --git a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl
index c9b90de..c2f83ec 100644
--- a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl
+++ b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl
@@ -6,7 +6,7 @@
environment:
sdk: ">=2.7.0 <3.0.0"
- flutter: ">=1.17.0 <2.0.0"
+ flutter: ">=1.20.0 <2.0.0"
dependencies:
flutter:
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart
index aa756d7..95a54b1 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart
@@ -280,7 +280,7 @@
return ProcessResult(0, 0, '000000000000000000000', '');
}
if (commandStr ==
- 'git describe --match *.*.*-*.*.pre --first-parent --long --tags') {
+ 'git describe --match *.*.* --first-parent --long --tags') {
if (version.isNotEmpty) {
return ProcessResult(0, 0, '$version-0-g00000000', '');
}
diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
index 8f39a74..9a9bb99 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
@@ -22,6 +22,7 @@
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
+import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
import '../../src/common.dart';
@@ -384,8 +385,8 @@
'android/src/main/java/com/example/flutter_project/FlutterProjectPlugin.java',
'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java',
'lib/flutter_project_web.dart',
- // TODO(cyanglaz): no-op iOS folder should be removed after 1.20.0 release
- // https://github.com/flutter/flutter/issues/59787
+ 'ios/Classes/FlutterProjectPlugin.m',
+ 'example/ios/Runner/AppDelegate.m',
],
);
return _runFlutterTest(projectDir.childDirectory('example'));
@@ -1531,18 +1532,14 @@
await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
- // TODO(cyanglaz): no-op iOS folder should be removed after 1.20.0 release
- // https://github.com/flutter/flutter/issues/59787
- expect(projectDir.childDirectory('ios').existsSync(), true);
+ expect(projectDir.childDirectory('ios').existsSync(), false);
expect(projectDir.childDirectory('android').existsSync(), false);
expect(projectDir.childDirectory('web').existsSync(), false);
expect(projectDir.childDirectory('linux').existsSync(), false);
expect(projectDir.childDirectory('windows').existsSync(), false);
expect(projectDir.childDirectory('macos').existsSync(), false);
- // TODO(cyanglaz): no-op iOS folder should be removed after 1.20.0 release
- // https://github.com/flutter/flutter/issues/59787
- expect(projectDir.childDirectory('example').childDirectory('ios').existsSync(), true);
+ expect(projectDir.childDirectory('example').childDirectory('ios').existsSync(), false);
expect(projectDir.childDirectory('example').childDirectory('android').existsSync(), false);
expect(projectDir.childDirectory('example').childDirectory('web').existsSync(), false);
expect(projectDir.childDirectory('example').childDirectory('linux').existsSync(), false);
@@ -1557,25 +1554,6 @@
});
- // TODO(cyanglaz): no-op iOS folder should be removed after 1.20.0 release
- // https://github.com/flutter/flutter/issues/59787
- testUsingContext('create an empty plugin contains a no-op ios folder, but no pubspec entry.', () async {
- Cache.flutterRoot = '../..';
- when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
- when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
-
- final CreateCommand command = CreateCommand();
- final CommandRunner<void> runner = createTestCommandRunner(command);
- await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
-
- expect(projectDir.childDirectory('ios').existsSync(), true);
- expect(projectDir.childDirectory('example').childDirectory('ios').existsSync(), true);
- validatePubspecForPlugin(projectDir: projectDir.absolute.path, expectedPlatforms: const <String>[
- 'some_platform'
- ], pluginClass: 'somePluginClass',
- unexpectedPlatforms: <String>['ios']);
- });
-
testUsingContext('plugin supports ios if requested', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
@@ -1945,6 +1923,21 @@
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
});
+ testUsingContext('newly created plugin has min flutter sdk version as 1.20.0', () async {
+ Cache.flutterRoot = '../..';
+ when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
+ when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
+
+ final CreateCommand command = CreateCommand();
+ final CommandRunner<void> runner = createTestCommandRunner(command);
+ await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
+ final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString();
+ final Pubspec pubspec = Pubspec.parse(rawPubspec);
+ final Map<String, VersionConstraint> env = pubspec.environment;
+ expect(env['flutter'].allows(Version(1, 20, 0)), true);
+ expect(env['flutter'].allows(Version(1, 19, 0)), false);
+ });
+
}
Future<void> _createProject(
diff --git a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
index 3fce718..8ce7b23 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
@@ -329,7 +329,7 @@
),
const FakeCommand(
command: <String>[
- 'git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags',
+ 'git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags',
],
stdout: 'v1.12.16-19-gb45b676af',
),
diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart
index 13655aa..ada250f 100644
--- a/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart
@@ -187,7 +187,7 @@
workingDirectory: Cache.flutterRoot)).thenReturn(result);
when(processManager.runSync('git tag --contains HEAD'.split(' '),
workingDirectory: Cache.flutterRoot)).thenReturn(result);
- when(processManager.runSync('git describe --match *.*.*-*.*.pre --first-parent --long --tags'.split(' '),
+ when(processManager.runSync('git describe --match *.*.* --first-parent --long --tags'.split(' '),
workingDirectory: Cache.flutterRoot)).thenReturn(result);
when(processManager.runSync(FlutterVersion.gitLog('-n 1 --pretty=format:%ad --date=iso'.split(' ')),
workingDirectory: Cache.flutterRoot)).thenReturn(result);
diff --git a/packages/flutter_tools/test/general.shard/version_test.dart b/packages/flutter_tools/test/general.shard/version_test.dart
index 1cd95ca..a889b84 100644
--- a/packages/flutter_tools/test/general.shard/version_test.dart
+++ b/packages/flutter_tools/test/general.shard/version_test.dart
@@ -418,7 +418,7 @@
expect(gitTagVersion.devPatch, 5);
gitTagVersion = GitTagVersion.parse('1.2.3-13-g$hash');
- expect(gitTagVersion.frameworkVersionFor(hash), '1.2.4.pre.13');
+ expect(gitTagVersion.frameworkVersionFor(hash), '1.2.4-0.0.pre.13');
expect(gitTagVersion.gitTag, '1.2.3');
expect(gitTagVersion.devVersion, null);
expect(gitTagVersion.devPatch, null);
@@ -432,12 +432,12 @@
// new tag release format, stable channel
gitTagVersion = GitTagVersion.parse('1.2.3-13-g$hash');
- expect(gitTagVersion.frameworkVersionFor(hash), '1.2.4.pre.13');
+ expect(gitTagVersion.frameworkVersionFor(hash), '1.2.4-0.0.pre.13');
expect(gitTagVersion.gitTag, '1.2.3');
expect(gitTagVersion.devVersion, null);
expect(gitTagVersion.devPatch, null);
- expect(GitTagVersion.parse('98.76.54-32-g$hash').frameworkVersionFor(hash), '98.76.55.pre.32');
+ expect(GitTagVersion.parse('98.76.54-32-g$hash').frameworkVersionFor(hash), '98.76.55-0.0.pre.32');
expect(GitTagVersion.parse('10.20.30-0-g$hash').frameworkVersionFor(hash), '10.20.30');
expect(testLogger.traceText, '');
expect(GitTagVersion.parse('v1.2.3+hotfix.1-4-g$hash').frameworkVersionFor(hash), '0.0.0-unknown');
@@ -474,7 +474,7 @@
// We shouldn't have to fallback to git describe, because we are exactly
// on a release tag.
verifyNever(mockProcessUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
));
@@ -488,7 +488,7 @@
environment: anyNamed('environment'),
)).thenReturn(RunResult(ProcessResult(105, 0, '', ''), <String>['git', 'fetch']));
when(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(RunResult(ProcessResult(106, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
@@ -514,7 +514,7 @@
environment: anyNamed('environment'),
));
verify(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
@@ -533,7 +533,7 @@
environment: anyNamed('environment'),
)).thenReturn(RunResult(ProcessResult(106, 0, '', ''), <String>['git', 'fetch']));
when(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(RunResult(ProcessResult(107, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
@@ -559,7 +559,7 @@
environment: anyNamed('environment'),
));
verify(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
@@ -586,7 +586,7 @@
<String>['git', 'tag', '--contains', 'HEAD'],
));
when(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(RunResult(ProcessResult(111, 0, 'v0.1.2-3-1234abcd', ''), <String>['git', 'describe']));
@@ -604,7 +604,7 @@
environment: anyNamed('environment'),
)).called(1);
verify(processUtils.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).called(1);
@@ -730,7 +730,7 @@
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(106, 0, '', ''));
when(pm.runSync(
- <String>['git', 'describe', '--match', '*.*.*-*.*.pre', '--first-parent', '--long', '--tags'],
+ <String>['git', 'describe', '--match', '*.*.*', '--first-parent', '--long', '--tags'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(107, 0, 'v0.1.2-3-1234abcd', ''));