From c4975d9be0e2f3ca6279ea4ba77b23cc549e2926 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 15 Jul 2022 11:12:43 -0700 Subject: [PATCH] Increase app minimum supported macOS version from 10.11 to 10.13 (#107689) --- dev/benchmarks/macrobenchmarks/macos/Podfile | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../flutter_gallery/macos/Podfile | 2 +- .../flutter_gallery/macos/Podfile.lock | 8 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- dev/integration_tests/ui/macos/Podfile | 2 +- .../ui/macos/Runner.xcodeproj/project.pbxproj | 6 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- packages/flutter_tools/bin/podhelper.rb | 6 +- .../src/commands/build_macos_framework.dart | 2 +- packages/flutter_tools/lib/src/ios/mac.dart | 4 +- ...t => ios_deployment_target_migration.dart} | 6 +- .../lib/src/macos/build_macos.dart | 2 + .../macos_deployment_target_migration.dart | 60 ++++ .../Runner.xcodeproj/project.pbxproj.tmpl | 6 +- .../templates/cocoapods/Podfile-macos | 2 +- .../ios/ios_project_migration_test.dart | 10 +- .../macos/macos_project_migration_test.dart | 296 ++++++++++++------ 21 files changed, 303 insertions(+), 147 deletions(-) rename packages/flutter_tools/lib/src/ios/migrations/{deployment_target_migration.dart => ios_deployment_target_migration.dart} (96%) create mode 100644 packages/flutter_tools/lib/src/macos/migrations/macos_deployment_target_migration.dart diff --git a/dev/benchmarks/macrobenchmarks/macos/Podfile b/dev/benchmarks/macrobenchmarks/macos/Podfile index dade8dfad0d..fe733905db6 100644 --- a/dev/benchmarks/macrobenchmarks/macos/Podfile +++ b/dev/benchmarks/macrobenchmarks/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.13' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.pbxproj b/dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.pbxproj index 8581681a212..c219f2103aa 100644 --- a/dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.pbxproj +++ b/dev/benchmarks/macrobenchmarks/macos/Runner.xcodeproj/project.pbxproj @@ -399,7 +399,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -478,7 +478,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -525,7 +525,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/dev/integration_tests/flutter_gallery/macos/Podfile b/dev/integration_tests/flutter_gallery/macos/Podfile index e8da8332969..85ce400a930 100644 --- a/dev/integration_tests/flutter_gallery/macos/Podfile +++ b/dev/integration_tests/flutter_gallery/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.13' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/dev/integration_tests/flutter_gallery/macos/Podfile.lock b/dev/integration_tests/flutter_gallery/macos/Podfile.lock index ddad43d5eba..318a6dfff2d 100644 --- a/dev/integration_tests/flutter_gallery/macos/Podfile.lock +++ b/dev/integration_tests/flutter_gallery/macos/Podfile.lock @@ -26,10 +26,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: connectivity_macos: 5dae6ee11d320fac7c05f0d08bd08fc32b5514d9 - FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 + FlutterMacOS: ff8bbbdbe83c20fe0f90a7cc96f00cf753baf5cc Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 - url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 + url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3 -PODFILE CHECKSUM: b5c36ba411e4471a03727d0463fa17be341876c1 +PODFILE CHECKSUM: 8719e666d6ae56e47eb36dbc2c8341bbe936a0e6 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/dev/integration_tests/flutter_gallery/macos/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/flutter_gallery/macos/Runner.xcodeproj/project.pbxproj index 018c7bec8a1..9d0f27a632c 100644 --- a/dev/integration_tests/flutter_gallery/macos/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/flutter_gallery/macos/Runner.xcodeproj/project.pbxproj @@ -506,7 +506,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -585,7 +585,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -632,7 +632,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/dev/integration_tests/ui/macos/Podfile b/dev/integration_tests/ui/macos/Podfile index dade8dfad0d..fe733905db6 100644 --- a/dev/integration_tests/ui/macos/Podfile +++ b/dev/integration_tests/ui/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.13' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/dev/integration_tests/ui/macos/Runner.xcodeproj/project.pbxproj b/dev/integration_tests/ui/macos/Runner.xcodeproj/project.pbxproj index aa8628ba995..4be2635eb54 100644 --- a/dev/integration_tests/ui/macos/Runner.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ui/macos/Runner.xcodeproj/project.pbxproj @@ -386,7 +386,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -465,7 +465,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -512,7 +512,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/dev/manual_tests/macos/Runner.xcodeproj/project.pbxproj b/dev/manual_tests/macos/Runner.xcodeproj/project.pbxproj index 1a4b4e8bace..c24604d263f 100644 --- a/dev/manual_tests/macos/Runner.xcodeproj/project.pbxproj +++ b/dev/manual_tests/macos/Runner.xcodeproj/project.pbxproj @@ -344,7 +344,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +423,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/examples/hello_world/macos/Runner.xcodeproj/project.pbxproj b/examples/hello_world/macos/Runner.xcodeproj/project.pbxproj index f4083e1e6f7..a202f1042ad 100644 --- a/examples/hello_world/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/hello_world/macos/Runner.xcodeproj/project.pbxproj @@ -344,7 +344,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +423,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/examples/image_list/macos/Runner.xcodeproj/project.pbxproj b/examples/image_list/macos/Runner.xcodeproj/project.pbxproj index 65e1baa895b..b5cd08891af 100644 --- a/examples/image_list/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/image_list/macos/Runner.xcodeproj/project.pbxproj @@ -344,7 +344,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +423,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/examples/layers/macos/Runner.xcodeproj/project.pbxproj b/examples/layers/macos/Runner.xcodeproj/project.pbxproj index bb1f36ef69f..6d9718e3b3e 100644 --- a/examples/layers/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/layers/macos/Runner.xcodeproj/project.pbxproj @@ -344,7 +344,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -422,7 +422,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -469,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/flutter_tools/bin/podhelper.rb b/packages/flutter_tools/bin/podhelper.rb index 972679c524e..0c79bff9229 100644 --- a/packages/flutter_tools/bin/podhelper.rb +++ b/packages/flutter_tools/bin/podhelper.rb @@ -95,11 +95,11 @@ def flutter_additional_macos_build_settings(target) # [target.deployment_target] is a [String] formatted as "10.8". deployment_target_major, deployment_target_minor = target.deployment_target.match(/(\d+).?(\d*)/).captures - # Suppress warning when pod supports a version lower than the minimum supported by the latest stable version of Xcode (currently 10.9). + # Suppress warning when pod supports a version lower than the minimum supported by the latest stable version of Xcode (currently 10.13). # This warning is harmless but confusing--it's not a bad thing for dependencies to support a lower version. inherit_deployment_target = !target.deployment_target.blank? && (deployment_target_major.to_i < 10) || - (deployment_target_major.to_i == 10 && deployment_target_minor.to_i < 9) + (deployment_target_major.to_i == 10 && deployment_target_minor.to_i < 13) # This podhelper script is at $FLUTTER_ROOT/packages/flutter_tools/bin. # Add search paths from $FLUTTER_ROOT/bin/cache/artifacts/engine. @@ -220,7 +220,7 @@ def flutter_install_macos_engine_pod(mac_application_path = nil) s.license = { :type => 'BSD' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } - s.osx.deployment_target = '10.11' + s.osx.deployment_target = '10.13' # Framework linking is handled by Flutter tooling, not CocoaPods. # Add a placeholder to satisfy `s.dependency 'FlutterMacOS'` plugin podspecs. s.vendored_frameworks = 'path/to/nothing' diff --git a/packages/flutter_tools/lib/src/commands/build_macos_framework.dart b/packages/flutter_tools/lib/src/commands/build_macos_framework.dart index 8bc3ee28c6c..c30ac643cac 100644 --- a/packages/flutter_tools/lib/src/commands/build_macos_framework.dart +++ b/packages/flutter_tools/lib/src/commands/build_macos_framework.dart @@ -162,7 +162,7 @@ LICENSE s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :http => '${cache.storageBaseUrl}/flutter_infra_release/flutter/${cache.engineRevision}/$artifactsMode/artifacts.zip' } s.documentation_url = 'https://flutter.dev/docs' - s.osx.deployment_target = '10.11' + s.osx.deployment_target = '10.13' s.vendored_frameworks = 'FlutterMacOS.framework' s.prepare_command = 'unzip FlutterMacOS.framework -d FlutterMacOS.framework' end diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 5d67e121280..4114d43febb 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -25,8 +25,8 @@ import '../reporting/reporting.dart'; import 'application_package.dart'; import 'code_signing.dart'; import 'iproxy.dart'; -import 'migrations/deployment_target_migration.dart'; import 'migrations/host_app_info_plist_migration.dart'; +import 'migrations/ios_deployment_target_migration.dart'; import 'migrations/project_base_configuration_migration.dart'; import 'migrations/project_build_location_migration.dart'; import 'migrations/project_object_version_migration.dart'; @@ -123,7 +123,7 @@ Future buildXcodeProject({ XcodeBuildSystemMigration(app.project, globals.logger), ProjectBaseConfigurationMigration(app.project, globals.logger), ProjectBuildLocationMigration(app.project, globals.logger), - DeploymentTargetMigration(app.project, globals.logger), + IOSDeploymentTargetMigration(app.project, globals.logger), ProjectObjectVersionMigration(app.project, globals.logger), HostAppInfoPlistMigration(app.project, globals.logger), ]; diff --git a/packages/flutter_tools/lib/src/ios/migrations/deployment_target_migration.dart b/packages/flutter_tools/lib/src/ios/migrations/ios_deployment_target_migration.dart similarity index 96% rename from packages/flutter_tools/lib/src/ios/migrations/deployment_target_migration.dart rename to packages/flutter_tools/lib/src/ios/migrations/ios_deployment_target_migration.dart index a1cabcc50b1..4376d403980 100644 --- a/packages/flutter_tools/lib/src/ios/migrations/deployment_target_migration.dart +++ b/packages/flutter_tools/lib/src/ios/migrations/ios_deployment_target_migration.dart @@ -7,8 +7,8 @@ import '../../base/project_migrator.dart'; import '../../xcode_project.dart'; /// Update the minimum iOS deployment version to the minimum allowed by Xcode without causing a warning. -class DeploymentTargetMigration extends ProjectMigrator { - DeploymentTargetMigration( +class IOSDeploymentTargetMigration extends ProjectMigrator { + IOSDeploymentTargetMigration( IosProject project, super.logger, ) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile, @@ -36,7 +36,7 @@ class DeploymentTargetMigration extends ProjectMigrator { if (_podfile.existsSync()) { processFileLines(_podfile); } else { - logger.printTrace('Podfile not found, skipping global platform version migration.'); + logger.printTrace('Podfile not found, skipping global platform iOS version migration.'); } return true; diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart index 1af3b7b0092..d872d89f9a7 100644 --- a/packages/flutter_tools/lib/src/macos/build_macos.dart +++ b/packages/flutter_tools/lib/src/macos/build_macos.dart @@ -14,6 +14,7 @@ import '../ios/xcode_build_settings.dart'; import '../ios/xcodeproj.dart'; import '../project.dart'; import 'cocoapod_utils.dart'; +import 'migrations/macos_deployment_target_migration.dart'; import 'migrations/remove_macos_framework_link_and_embedding_migration.dart'; /// When run in -quiet mode, Xcode should only print from the underlying tasks to stdout. @@ -45,6 +46,7 @@ Future buildMacOS({ globals.logger, globals.flutterUsage, ), + MacOSDeploymentTargetMigration(flutterProject.macos, globals.logger), ]; final ProjectMigration migration = ProjectMigration(migrators); diff --git a/packages/flutter_tools/lib/src/macos/migrations/macos_deployment_target_migration.dart b/packages/flutter_tools/lib/src/macos/migrations/macos_deployment_target_migration.dart new file mode 100644 index 00000000000..58ce9fb7df1 --- /dev/null +++ b/packages/flutter_tools/lib/src/macos/migrations/macos_deployment_target_migration.dart @@ -0,0 +1,60 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../../base/file_system.dart'; +import '../../base/project_migrator.dart'; +import '../../xcode_project.dart'; + +/// Update the minimum macOS deployment version to the minimum allowed by Xcode without causing a warning. +class MacOSDeploymentTargetMigration extends ProjectMigrator { + MacOSDeploymentTargetMigration( + MacOSProject project, + super.logger, + ) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile, + _podfile = project.podfile; + + final File _xcodeProjectInfoFile; + final File _podfile; + + @override + bool migrate() { + if (_xcodeProjectInfoFile.existsSync()) { + processFileLines(_xcodeProjectInfoFile); + } else { + logger.printTrace('Xcode project not found, skipping macOS deployment target version migration.'); + } + + if (_podfile.existsSync()) { + processFileLines(_podfile); + } else { + logger.printTrace('Podfile not found, skipping global platform macOS version migration.'); + } + + return true; + } + + @override + String? migrateLine(String line) { + // Xcode project file changes. + const String deploymentTargetOriginal = 'MACOSX_DEPLOYMENT_TARGET = 10.11;'; + + // Podfile changes. + const String podfilePlatformVersionOriginal = "platform :osx, '10.11'"; + + if (line.contains(deploymentTargetOriginal) || line.contains(podfilePlatformVersionOriginal)) { + if (!migrationRequired) { + // Only print for the first discovered change found. + logger.printStatus('Updating minimum macOS deployment target to 10.13.'); + } + + const String deploymentTargetReplacement = 'MACOSX_DEPLOYMENT_TARGET = 10.13;'; + const String podfilePlatformVersionReplacement = "platform :osx, '10.13'"; + return line + .replaceAll(deploymentTargetOriginal, deploymentTargetReplacement) + .replaceAll(podfilePlatformVersionOriginal, podfilePlatformVersionReplacement); + } + + return line; + } +} diff --git a/packages/flutter_tools/templates/app_shared/macos.tmpl/Runner.xcodeproj/project.pbxproj.tmpl b/packages/flutter_tools/templates/app_shared/macos.tmpl/Runner.xcodeproj/project.pbxproj.tmpl index b992f1aa153..65ed3d85f37 100644 --- a/packages/flutter_tools/templates/app_shared/macos.tmpl/Runner.xcodeproj/project.pbxproj.tmpl +++ b/packages/flutter_tools/templates/app_shared/macos.tmpl/Runner.xcodeproj/project.pbxproj.tmpl @@ -344,7 +344,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +423,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-macos b/packages/flutter_tools/templates/cocoapods/Podfile-macos index dade8dfad0d..fe733905db6 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-macos +++ b/packages/flutter_tools/templates/cocoapods/Podfile-macos @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.13' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart index ef08b9497f9..4c43180d978 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart @@ -6,8 +6,8 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/project_migrator.dart'; -import 'package:flutter_tools/src/ios/migrations/deployment_target_migration.dart'; import 'package:flutter_tools/src/ios/migrations/host_app_info_plist_migration.dart'; +import 'package:flutter_tools/src/ios/migrations/ios_deployment_target_migration.dart'; import 'package:flutter_tools/src/ios/migrations/project_base_configuration_migration.dart'; import 'package:flutter_tools/src/ios/migrations/project_build_location_migration.dart'; import 'package:flutter_tools/src/ios/migrations/project_object_version_migration.dart'; @@ -514,7 +514,7 @@ keep this 3 }); testWithoutContext('skipped if files are missing', () { - final DeploymentTargetMigration iosProjectMigration = DeploymentTargetMigration( + final IOSDeploymentTargetMigration iosProjectMigration = IOSDeploymentTargetMigration( project, testLogger, ); @@ -525,7 +525,7 @@ keep this 3 expect(testLogger.traceText, contains('Xcode project not found, skipping iOS deployment target version migration')); expect(testLogger.traceText, contains('AppFrameworkInfo.plist not found, skipping minimum OS version migration')); - expect(testLogger.traceText, contains('Podfile not found, skipping global platform version migration')); + expect(testLogger.traceText, contains('Podfile not found, skipping global platform iOS version migration')); expect(testLogger.statusText, isEmpty); }); @@ -545,7 +545,7 @@ keep this 3 podfile.writeAsStringSync(podfileFileContents); final DateTime podfileLastModified = podfile.lastModifiedSync(); - final DeploymentTargetMigration iosProjectMigration = DeploymentTargetMigration( + final IOSDeploymentTargetMigration iosProjectMigration = IOSDeploymentTargetMigration( project, testLogger, ); @@ -591,7 +591,7 @@ keep this 3 platform :ios, '9.0' '''); - final DeploymentTargetMigration iosProjectMigration = DeploymentTargetMigration( + final IOSDeploymentTargetMigration iosProjectMigration = IOSDeploymentTargetMigration( project, testLogger, ); diff --git a/packages/flutter_tools/test/general.shard/macos/macos_project_migration_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_project_migration_test.dart index 380508f389a..693122ca5d8 100644 --- a/packages/flutter_tools/test/general.shard/macos/macos_project_migration_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/macos_project_migration_test.dart @@ -5,6 +5,7 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/logger.dart'; +import 'package:flutter_tools/src/macos/migrations/macos_deployment_target_migration.dart'; import 'package:flutter_tools/src/macos/migrations/remove_macos_framework_link_and_embedding_migration.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/xcode_project.dart'; @@ -13,80 +14,81 @@ import 'package:test/fake.dart'; import '../../src/common.dart'; void main() { - late TestUsage testUsage; - late MemoryFileSystem memoryFileSystem; - late BufferLogger testLogger; - late FakeMacOSProject macOSProject; - late File xcodeProjectInfoFile; + group('remove link and embed migration', () { + late TestUsage testUsage; + late MemoryFileSystem memoryFileSystem; + late BufferLogger testLogger; + late FakeMacOSProject macOSProject; + late File xcodeProjectInfoFile; - setUp(() { - testUsage = TestUsage(); - memoryFileSystem = MemoryFileSystem.test(); - xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); - testLogger = BufferLogger.test(); - macOSProject = FakeMacOSProject(); - macOSProject.xcodeProjectInfoFile = xcodeProjectInfoFile; - }); + setUp(() { + testUsage = TestUsage(); + memoryFileSystem = MemoryFileSystem.test(); + xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); + testLogger = BufferLogger.test(); + macOSProject = FakeMacOSProject(); + macOSProject.xcodeProjectInfoFile = xcodeProjectInfoFile; + }); - testWithoutContext('skipped if files are missing', () { - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); - expect(macosProjectMigration.migrate(), isTrue); - expect(testUsage.events, isEmpty); + testWithoutContext('skipped if files are missing', () { + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); + expect(macosProjectMigration.migrate(), isTrue); + expect(testUsage.events, isEmpty); - expect(xcodeProjectInfoFile.existsSync(), isFalse); + expect(xcodeProjectInfoFile.existsSync(), isFalse); - expect( - testLogger.traceText, - contains( - 'Xcode project not found, skipping framework link and embedding migration')); - expect(testLogger.statusText, isEmpty); - }); + expect( + testLogger.traceText, + contains( + 'Xcode project not found, skipping framework link and embedding migration')); + expect(testLogger.statusText, isEmpty); + }); - testWithoutContext('skipped if nothing to upgrade', () { - const String contents = 'Nothing to upgrade'; - xcodeProjectInfoFile.writeAsStringSync(contents); - final DateTime projectLastModified = - xcodeProjectInfoFile.lastModifiedSync(); + testWithoutContext('skipped if nothing to upgrade', () { + const String contents = 'Nothing to upgrade'; + xcodeProjectInfoFile.writeAsStringSync(contents); + final DateTime projectLastModified = + xcodeProjectInfoFile.lastModifiedSync(); - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); - expect(macosProjectMigration.migrate(), isTrue); - expect(testUsage.events, isEmpty); + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); + expect(macosProjectMigration.migrate(), isTrue); + expect(testUsage.events, isEmpty); - expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified); - expect(xcodeProjectInfoFile.readAsStringSync(), contents); + expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified); + expect(xcodeProjectInfoFile.readAsStringSync(), contents); - expect(testLogger.statusText, isEmpty); - }); + expect(testLogger.statusText, isEmpty); + }); - testWithoutContext('skips migrating script with embed', () { - const String contents = r''' + testWithoutContext('skips migrating script with embed', () { + const String contents = r''' shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; '''; - xcodeProjectInfoFile.writeAsStringSync(contents); + xcodeProjectInfoFile.writeAsStringSync(contents); - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); - expect(macosProjectMigration.migrate(), isTrue); - expect(xcodeProjectInfoFile.readAsStringSync(), contents); - expect(testLogger.statusText, isEmpty); - }); + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); + expect(macosProjectMigration.migrate(), isTrue); + expect(xcodeProjectInfoFile.readAsStringSync(), contents); + expect(testLogger.statusText, isEmpty); + }); - testWithoutContext('Xcode project is migrated', () { - xcodeProjectInfoFile.writeAsStringSync(r''' + testWithoutContext('Xcode project is migrated', () { + xcodeProjectInfoFile.writeAsStringSync(r''' prefix D73912F022F37F9E000D13A0 D73912F222F3801D000D13A0 suffix D73912EF22F37F9E000D13A0 @@ -97,64 +99,156 @@ keep this 1 keep this 2 '''); - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); - expect(macosProjectMigration.migrate(), isTrue); - expect(testUsage.events, isEmpty); + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); + expect(macosProjectMigration.migrate(), isTrue); + expect(testUsage.events, isEmpty); - expect(xcodeProjectInfoFile.readAsStringSync(), r''' + expect(xcodeProjectInfoFile.readAsStringSync(), r''' keep this 1 shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; keep this 2 '''); - expect(testLogger.statusText, contains('Upgrading project.pbxproj')); - }); + expect(testLogger.statusText, contains('Upgrading project.pbxproj')); + }); - testWithoutContext('migration fails with leftover App.framework reference', - () { - xcodeProjectInfoFile.writeAsStringSync(''' + testWithoutContext('migration fails with leftover App.framework reference', () { + xcodeProjectInfoFile.writeAsStringSync(''' D73912F022F37F9bogus /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912F022F37F9bogus /* App.framework */; }; '''); - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); - expect(macosProjectMigration.migrate, - throwsToolExit(message: 'Your Xcode project requires migration')); - expect(testUsage.events, contains( - const TestUsageEvent('macos-migration', 'remove-frameworks', label: 'failure'), - )); - }); + expect(macosProjectMigration.migrate, + throwsToolExit(message: 'Your Xcode project requires migration')); + expect(testUsage.events, contains( + const TestUsageEvent('macos-migration', 'remove-frameworks', label: 'failure'), + )); + }); - testWithoutContext( - 'migration fails with leftover FlutterMacOS.framework reference', () { - xcodeProjectInfoFile.writeAsStringSync(''' + testWithoutContext( + 'migration fails with leftover FlutterMacOS.framework reference', () { + xcodeProjectInfoFile.writeAsStringSync(''' 33D1A10522148B93bogus /* FlutterMacOS.framework in Bundle Framework */, '''); - final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = - RemoveMacOSFrameworkLinkAndEmbeddingMigration( - macOSProject, - testLogger, - testUsage, - ); - expect(macosProjectMigration.migrate, - throwsToolExit(message: 'Your Xcode project requires migration')); - expect(testUsage.events, contains( - const TestUsageEvent('macos-migration', 'remove-frameworks', label: 'failure'), - )); + final RemoveMacOSFrameworkLinkAndEmbeddingMigration macosProjectMigration = + RemoveMacOSFrameworkLinkAndEmbeddingMigration( + macOSProject, + testLogger, + testUsage, + ); + expect(macosProjectMigration.migrate, + throwsToolExit(message: 'Your Xcode project requires migration')); + expect(testUsage.events, contains( + const TestUsageEvent('macos-migration', 'remove-frameworks', label: 'failure'), + )); + }); + }); + + group('update deployment target version', () { + late MemoryFileSystem memoryFileSystem; + late BufferLogger testLogger; + late FakeMacOSProject project; + late File xcodeProjectInfoFile; + late File podfile; + + setUp(() { + memoryFileSystem = MemoryFileSystem(); + testLogger = BufferLogger.test(); + project = FakeMacOSProject(); + xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); + project.xcodeProjectInfoFile = xcodeProjectInfoFile; + + podfile = memoryFileSystem.file('Podfile'); + project.podfile = podfile; + }); + + testWithoutContext('skipped if files are missing', () { + final MacOSDeploymentTargetMigration macOSProjectMigration = MacOSDeploymentTargetMigration( + project, + testLogger, + ); + expect(macOSProjectMigration.migrate(), isTrue); + expect(xcodeProjectInfoFile.existsSync(), isFalse); + expect(podfile.existsSync(), isFalse); + + expect(testLogger.traceText, contains('Xcode project not found, skipping macOS deployment target version migration')); + expect(testLogger.traceText, contains('Podfile not found, skipping global platform macOS version migration')); + expect(testLogger.statusText, isEmpty); + }); + + testWithoutContext('skipped if nothing to upgrade', () { + const String xcodeProjectInfoFileContents = 'IPHONEOS_DEPLOYMENT_TARGET = 11.0;'; + xcodeProjectInfoFile.writeAsStringSync(xcodeProjectInfoFileContents); + + final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync(); + + const String podfileFileContents = "# platform :osx, '10.13'"; + podfile.writeAsStringSync(podfileFileContents); + final DateTime podfileLastModified = podfile.lastModifiedSync(); + + final MacOSDeploymentTargetMigration macOSProjectMigration = MacOSDeploymentTargetMigration( + project, + testLogger, + ); + expect(macOSProjectMigration.migrate(), isTrue); + + expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified); + expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents); + expect(podfile.lastModifiedSync(), podfileLastModified); + expect(podfile.readAsStringSync(), podfileFileContents); + + expect(testLogger.statusText, isEmpty); + }); + + testWithoutContext('Xcode project is migrated to 10.13', () { + xcodeProjectInfoFile.writeAsStringSync(''' + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; +'''); + + podfile.writeAsStringSync(''' +# platform :osx, '10.11' +platform :osx, '10.11' +'''); + + final MacOSDeploymentTargetMigration macOSProjectMigration = MacOSDeploymentTargetMigration( + project, + testLogger, + ); + expect(macOSProjectMigration.migrate(), isTrue); + + expect(xcodeProjectInfoFile.readAsStringSync(), ''' + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = YES; +'''); + + expect(podfile.readAsStringSync(), ''' +# platform :osx, '10.13' +platform :osx, '10.13' +'''); + // Only print once even though 2 lines were changed. + expect('Updating minimum macOS deployment target to 10.13'.allMatches(testLogger.statusText).length, 1); + }); }); } class FakeMacOSProject extends Fake implements MacOSProject { @override File xcodeProjectInfoFile = MemoryFileSystem.test().file('xcodeProjectInfoFile'); + + @override + File podfile = MemoryFileSystem.test().file('Podfile'); }