Unverified Commit 9136a474 authored by Victoria Ashworth's avatar Victoria Ashworth Committed by GitHub

Set plugin template minimum iOS version to 11.0 (#122625)

Set plugin template minimum iOS version to 11.0
parent 783a367d
...@@ -346,7 +346,7 @@ public class $pluginClass: NSObject, FlutterPlugin { ...@@ -346,7 +346,7 @@ public class $pluginClass: NSObject, FlutterPlugin {
throw TaskResult.failure('podspec file missing at ${podspec.path}'); throw TaskResult.failure('podspec file missing at ${podspec.path}');
} }
final String versionString = target == 'ios' final String versionString = target == 'ios'
? "s.platform = :ios, '9.0'" ? "s.platform = :ios, '11.0'"
: "s.platform = :osx, '10.11'"; : "s.platform = :osx, '10.11'";
String podspecContent = podspec.readAsStringSync(); String podspecContent = podspec.readAsStringSync();
if (!podspecContent.contains(versionString)) { if (!podspecContent.contains(versionString)) {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import '../android/android.dart' as android_common; import '../android/android.dart' as android_common;
...@@ -381,12 +380,6 @@ abstract class CreateBase extends FlutterCommand { ...@@ -381,12 +380,6 @@ abstract class CreateBase extends FlutterCommand {
// https://developer.gnome.org/gio/stable/GApplication.html#g-application-id-is-valid // https://developer.gnome.org/gio/stable/GApplication.html#g-application-id-is-valid
final String linuxIdentifier = androidIdentifier; 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 <String, Object?>{ return <String, Object?>{
'organization': organization, 'organization': organization,
'projectName': projectName, 'projectName': projectName,
...@@ -416,7 +409,6 @@ abstract class CreateBase extends FlutterCommand { ...@@ -416,7 +409,6 @@ abstract class CreateBase extends FlutterCommand {
'iosDevelopmentTeam': iosDevelopmentTeam ?? '', 'iosDevelopmentTeam': iosDevelopmentTeam ?? '',
'flutterRevision': globals.flutterVersion.frameworkRevision, 'flutterRevision': globals.flutterVersion.frameworkRevision,
'flutterChannel': globals.flutterVersion.channel, 'flutterChannel': globals.flutterVersion.channel,
'minFrameworkVersionFfiPlugin': minFrameworkVersionFfiPlugin,
'ios': ios, 'ios': ios,
'android': android, 'android': android,
'web': web, 'web': web,
......
...@@ -16,7 +16,7 @@ Pod::Spec.new do |s| ...@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source_files = 'Classes/**/*' s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h' s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '9.0' s.platform = :ios, '11.0'
# Flutter.framework does not contain a i386 slice. # Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
......
...@@ -15,7 +15,7 @@ Pod::Spec.new do |s| ...@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.source = { :path => '.' } s.source = { :path => '.' }
s.source_files = 'Classes/**/*' s.source_files = 'Classes/**/*'
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '9.0' s.platform = :ios, '11.0'
# Flutter.framework does not contain a i386 slice. # Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
......
...@@ -20,7 +20,7 @@ Pod::Spec.new do |s| ...@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.source = { :path => '.' } s.source = { :path => '.' }
s.source_files = 'Classes/**/*' s.source_files = 'Classes/**/*'
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '9.0' s.platform = :ios, '11.0'
# Flutter.framework does not contain a i386 slice. # Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
......
...@@ -5,12 +5,7 @@ homepage: ...@@ -5,12 +5,7 @@ homepage:
environment: environment:
sdk: {{dartSdkVersionBounds}} sdk: {{dartSdkVersionBounds}}
{{#withPlatformChannelPluginHook}} flutter: ">=3.3.0"
flutter: ">=2.5.0"
{{/withPlatformChannelPluginHook}}
{{#withFfiPluginHook}}
flutter: ">={{minFrameworkVersionFfiPlugin}}"
{{/withFfiPluginHook}}
dependencies: dependencies:
flutter: flutter:
......
...@@ -2762,7 +2762,7 @@ void main() { ...@@ -2762,7 +2762,7 @@ void main() {
Logger: () => logger, 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 = '../..'; Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand(); final CreateCommand command = CreateCommand();
...@@ -2771,8 +2771,54 @@ void main() { ...@@ -2771,8 +2771,54 @@ void main() {
final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString(); final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString();
final Pubspec pubspec = Pubspec.parse(rawPubspec); final Pubspec pubspec = Pubspec.parse(rawPubspec);
final Map<String, VersionConstraint?> env = pubspec.environment!; final Map<String, VersionConstraint?> env = pubspec.environment!;
expect(env['flutter']!.allows(Version(2, 5, 0)), true); expect(env['flutter']!.allows(Version(3, 3, 0)), true);
expect(env['flutter']!.allows(Version(2, 4, 9)), false); 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<String> iosPluginTemplates = <String>[
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<void> runner = createTestCommandRunner(command);
await runner.run(<String>['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 { testUsingContext('default app uses flutter default versions', () async {
......
...@@ -88,18 +88,11 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage"; ...@@ -88,18 +88,11 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage";
CGRect screenshotBounds = window.bounds; CGRect screenshotBounds = window.bounds;
UIImage *image; UIImage *image;
if (@available(iOS 10, *)) {
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithBounds:screenshotBounds]; UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithBounds:screenshotBounds];
image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) { image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) {
[window drawViewHierarchyInRect:screenshotBounds afterScreenUpdates:YES]; [window drawViewHierarchyInRect:screenshotBounds afterScreenUpdates:YES];
}]; }];
} else {
UIGraphicsBeginImageContextWithOptions(screenshotBounds.size, NO, UIScreen.mainScreen.scale);
[window drawViewHierarchyInRect:screenshotBounds afterScreenUpdates:YES];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return image; return image;
} }
......
...@@ -20,6 +20,6 @@ LICENSE ...@@ -20,6 +20,6 @@ LICENSE
s.dependency 'Flutter' s.dependency 'Flutter'
s.ios.framework = 'UIKit' 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' } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment