diff --git a/dev/devicelab/lib/tasks/plugin_tests.dart b/dev/devicelab/lib/tasks/plugin_tests.dart index 90f74ee368..81798a8290 100644 --- a/dev/devicelab/lib/tasks/plugin_tests.dart +++ b/dev/devicelab/lib/tasks/plugin_tests.dart @@ -37,12 +37,12 @@ class PluginTest { try { section('Create plugin'); final _FlutterProject plugin = await _FlutterProject.create( - tempDir, options, + tempDir, options, buildTarget, name: 'plugintest', template: 'plugin', environment: pluginCreateEnvironment); section('Test plugin'); await plugin.test(); section('Create Flutter app'); - final _FlutterProject app = await _FlutterProject.create(tempDir, options, + final _FlutterProject app = await _FlutterProject.create(tempDir, options, buildTarget, name: 'plugintestapp', template: 'app', environment: appCreateEnvironment); try { section('Add plugins'); @@ -95,6 +95,7 @@ class _FlutterProject { static Future<_FlutterProject> create( Directory directory, List options, + String target, { String name, String template, @@ -113,12 +114,46 @@ class _FlutterProject { environment: environment, ); }); - return _FlutterProject(directory, name); + + final _FlutterProject project = _FlutterProject(directory, name); + if (template == 'plugin' && target == 'ios') { + project._reduceIOSPluginMinimumVersion(name); + } + return project; + } + + // Make the platform version artificially low to test that the "deployment + // version too low" warning is never emitted. + void _reduceIOSPluginMinimumVersion(String plugin) { + final File podspec = File(path.join(rootPath, 'ios', '$plugin.podspec')); + if (!podspec.existsSync()) { + throw TaskResult.failure('podspec file missing at ${podspec.path}'); + } + const String versionString = "s.platform = :ios, '8.0'"; + String podspecContent = podspec.readAsStringSync(); + if (!podspecContent.contains(versionString)) { + throw TaskResult.failure('Update this test to match plugin minimum iOS deployment version'); + } + podspecContent = podspecContent.replaceFirst( + versionString, + "s.platform = :ios, '7.0'", + ); + podspec.writeAsStringSync(podspecContent, flush: true); } Future build(String target) async { await inDirectory(Directory(rootPath), () async { - await flutter('build', options: [target]); + final String buildOutput = await evalFlutter('build', options: [target, '-v']); + + if (target == 'ios') { + // This warning is confusing and shouldn't be emitted. Plugins often support lower versions than the + // Flutter app, but as long as they support the minimum it will work. + // warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, + // but the range of supported deployment target versions is 9.0 to 14.0.99. + if (buildOutput.contains('the range of supported deployment target versions')) { + throw TaskResult.failure('Minimum plugin version warning present'); + } + } }); } diff --git a/packages/flutter_tools/bin/podhelper.rb b/packages/flutter_tools/bin/podhelper.rb index 9999ab9020..769484019f 100644 --- a/packages/flutter_tools/bin/podhelper.rb +++ b/packages/flutter_tools/bin/podhelper.rb @@ -27,8 +27,17 @@ end # end # @param [PBXAggregateTarget] target Pod target. def flutter_additional_ios_build_settings(target) + return unless target.platform_name == :ios + + # [target.deployment_target] is a [String] formatted as "8.0". + inherit_deployment_target = target.deployment_target[/\d+/].to_i < 9 target.build_configurations.each do |build_configuration| - build_configuration.build_settings['ENABLE_BITCODE'] = 'NO' + build_configuration.build_settings['ENABLE_BITCODE'] = 'NO' + # Suppress warning when pod supports a version lower than the minimum supported by Xcode (Xcode 12 - iOS 9). + # This warning is harmless but confusing--it's not a bad thing for dependencies to support a lower version. + # When deleted, the deployment version will inherit from the higher version derived from the 'Runner' target. + # If the pod only supports a higher version, do not delete to correctly produce an error. + build_configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' if inherit_deployment_target end end diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index 88101376c1..ec61885752 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -240,6 +240,12 @@ class AOTSnapshotter { final List commonBuildOptions = [ '-arch', targetArch, if (isIOS) + // When the minimum version is updated, remember to update + // template IPHONEOS_DEPLOYMENT_TARGET and MinimumOSVersion. + // https://github.com/flutter/flutter/pull/62902 + // Also update the podhelper.rb "deployment version too low" + // warning suppression version. + // https://github.com/flutter/flutter/pull/66590 '-miphoneos-version-min=9.0', ];