From 9136a474589722e28c49b167b3c87d26775f2d19 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Tue, 21 Mar 2023 11:40:50 -0500 Subject: [PATCH] Set plugin template minimum iOS version to 11.0 (#122625) Set plugin template minimum iOS version to 11.0 --- dev/devicelab/lib/tasks/plugin_tests.dart | 2 +- .../lib/src/commands/create_base.dart | 8 --- .../ios-objc.tmpl/projectName.podspec.tmpl | 2 +- .../ios-swift.tmpl/projectName.podspec.tmpl | 2 +- .../ios.tmpl/projectName.podspec.tmpl | 2 +- .../templates/plugin_shared/pubspec.yaml.tmpl | 7 +-- .../commands.shard/permeable/create_test.dart | 52 +++++++++++++++++-- .../ios/Classes/IntegrationTestPlugin.m | 13 ++--- .../ios/integration_test.podspec | 2 +- 9 files changed, 58 insertions(+), 32 deletions(-) diff --git a/dev/devicelab/lib/tasks/plugin_tests.dart b/dev/devicelab/lib/tasks/plugin_tests.dart index ccb8330c72c..d6ec81682f8 100644 --- a/dev/devicelab/lib/tasks/plugin_tests.dart +++ b/dev/devicelab/lib/tasks/plugin_tests.dart @@ -346,7 +346,7 @@ public class $pluginClass: NSObject, FlutterPlugin { throw TaskResult.failure('podspec file missing at ${podspec.path}'); } final String versionString = target == 'ios' - ? "s.platform = :ios, '9.0'" + ? "s.platform = :ios, '11.0'" : "s.platform = :osx, '10.11'"; String podspecContent = podspec.readAsStringSync(); if (!podspecContent.contains(versionString)) { diff --git a/packages/flutter_tools/lib/src/commands/create_base.dart b/packages/flutter_tools/lib/src/commands/create_base.dart index cde0e989e71..c8dba571c5d 100644 --- a/packages/flutter_tools/lib/src/commands/create_base.dart +++ b/packages/flutter_tools/lib/src/commands/create_base.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:meta/meta.dart'; -import 'package:pub_semver/pub_semver.dart'; import 'package:uuid/uuid.dart'; import '../android/android.dart' as android_common; @@ -381,12 +380,6 @@ abstract class CreateBase extends FlutterCommand { // https://developer.gnome.org/gio/stable/GApplication.html#g-application-id-is-valid final String linuxIdentifier = androidIdentifier; - // TODO(dacoharkes): Replace with hardcoded version in template when Flutter 2.11 is released. - final Version ffiPluginStableRelease = Version(2, 11, 0); - final String minFrameworkVersionFfiPlugin = Version.parse(globals.flutterVersion.frameworkVersion) < ffiPluginStableRelease - ? globals.flutterVersion.frameworkVersion - : ffiPluginStableRelease.toString(); - return { 'organization': organization, 'projectName': projectName, @@ -416,7 +409,6 @@ abstract class CreateBase extends FlutterCommand { 'iosDevelopmentTeam': iosDevelopmentTeam ?? '', 'flutterRevision': globals.flutterVersion.frameworkRevision, 'flutterChannel': globals.flutterVersion.channel, - 'minFrameworkVersionFfiPlugin': minFrameworkVersionFfiPlugin, 'ios': ios, 'android': android, 'web': web, diff --git a/packages/flutter_tools/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl b/packages/flutter_tools/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl index 6f0a53c7b86..e44da71ca78 100644 --- a/packages/flutter_tools/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl +++ b/packages/flutter_tools/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.platform = :ios, '9.0' + s.platform = :ios, '11.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl b/packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl index 1760c3f6982..bbdb51c6628 100644 --- a/packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl +++ b/packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.platform = :ios, '9.0' + s.platform = :ios, '11.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/packages/flutter_tools/templates/plugin_ffi/ios.tmpl/projectName.podspec.tmpl b/packages/flutter_tools/templates/plugin_ffi/ios.tmpl/projectName.podspec.tmpl index b914d852bcb..7a5c3049360 100644 --- a/packages/flutter_tools/templates/plugin_ffi/ios.tmpl/projectName.podspec.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/ios.tmpl/projectName.podspec.tmpl @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.platform = :ios, '9.0' + s.platform = :ios, '11.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl b/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl index df5ad09c013..8641c2f35cc 100644 --- a/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/plugin_shared/pubspec.yaml.tmpl @@ -5,12 +5,7 @@ homepage: environment: sdk: {{dartSdkVersionBounds}} -{{#withPlatformChannelPluginHook}} - flutter: ">=2.5.0" -{{/withPlatformChannelPluginHook}} -{{#withFfiPluginHook}} - flutter: ">={{minFrameworkVersionFfiPlugin}}" -{{/withFfiPluginHook}} + flutter: ">=3.3.0" dependencies: flutter: 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 e07f1a5149a..3d8568e5caf 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -2762,7 +2762,7 @@ void main() { Logger: () => logger, }); - testUsingContext('newly created plugin has min flutter sdk version as 2.5.0', () async { + testUsingContext('newly created plugin has min flutter sdk version as 3.3.0', () async { Cache.flutterRoot = '../..'; final CreateCommand command = CreateCommand(); @@ -2771,8 +2771,54 @@ void main() { final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString(); final Pubspec pubspec = Pubspec.parse(rawPubspec); final Map env = pubspec.environment!; - expect(env['flutter']!.allows(Version(2, 5, 0)), true); - expect(env['flutter']!.allows(Version(2, 4, 9)), false); + expect(env['flutter']!.allows(Version(3, 3, 0)), true); + expect(env['flutter']!.allows(Version(3, 2, 9)), false); + }); + + testUsingContext('newly created iOS plugins has min iOS version of 11.0', () async { + Cache.flutterRoot = '../..'; + final String flutterToolsAbsolutePath = globals.fs.path.join( + Cache.flutterRoot!, + 'packages', + 'flutter_tools', + ); + final List iosPluginTemplates = [ + globals.fs.path.join( + flutterToolsAbsolutePath, + 'templates', + 'plugin', + 'ios-objc.tmpl', + 'projectName.podspec.tmpl', + ), + globals.fs.path.join( + flutterToolsAbsolutePath, + 'templates', + 'plugin', + 'ios-swift.tmpl', + 'projectName.podspec.tmpl', + ), + globals.fs.path.join( + flutterToolsAbsolutePath, + 'templates', + 'plugin_ffi', + 'ios.tmpl', + 'projectName.podspec.tmpl', + ), + ]; + + for (final String templatePath in iosPluginTemplates) { + final String rawTemplate = globals.fs.file(templatePath).readAsStringSync(); + expect(rawTemplate, contains("s.platform = :ios, '11.0'")); + } + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + await runner.run(['create', '--no-pub', '--template=plugin', '--platform=ios', projectDir.path]); + + expect(projectDir.childDirectory('ios').childFile('flutter_project.podspec'), + exists); + final String rawPodSpec = await projectDir.childDirectory('ios').childFile('flutter_project.podspec').readAsString(); + expect(rawPodSpec, contains("s.platform = :ios, '11.0'")); }); testUsingContext('default app uses flutter default versions', () async { diff --git a/packages/integration_test/ios/Classes/IntegrationTestPlugin.m b/packages/integration_test/ios/Classes/IntegrationTestPlugin.m index a8a80b6785b..fc2dc54246d 100644 --- a/packages/integration_test/ios/Classes/IntegrationTestPlugin.m +++ b/packages/integration_test/ios/Classes/IntegrationTestPlugin.m @@ -88,18 +88,11 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage"; CGRect screenshotBounds = window.bounds; UIImage *image; - if (@available(iOS 10, *)) { - UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithBounds:screenshotBounds]; + UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithBounds:screenshotBounds]; - image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) { - [window drawViewHierarchyInRect:screenshotBounds afterScreenUpdates:YES]; - }]; - } else { - UIGraphicsBeginImageContextWithOptions(screenshotBounds.size, NO, UIScreen.mainScreen.scale); + image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) { [window drawViewHierarchyInRect:screenshotBounds afterScreenUpdates:YES]; - image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - } + }]; return image; } diff --git a/packages/integration_test/ios/integration_test.podspec b/packages/integration_test/ios/integration_test.podspec index 39f9dbfefa4..0a67820711e 100644 --- a/packages/integration_test/ios/integration_test.podspec +++ b/packages/integration_test/ios/integration_test.podspec @@ -20,6 +20,6 @@ LICENSE s.dependency 'Flutter' s.ios.framework = 'UIKit' - s.platform = :ios, '9.0' + s.platform = :ios, '11.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } end