From d8fa5d6b27f2da8a51a62d5dd4cb2526414c6cd8 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 16 May 2022 14:01:00 -0400 Subject: [PATCH 1/4] Add tool flags --- script/tool/CHANGELOG.md | 3 + .../tool/lib/src/xcode_analyze_command.dart | 25 +++++- .../tool/test/xcode_analyze_command_test.dart | 76 +++++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) diff --git a/script/tool/CHANGELOG.md b/script/tool/CHANGELOG.md index a8a8268c047f..4d710d3fa894 100644 --- a/script/tool/CHANGELOG.md +++ b/script/tool/CHANGELOG.md @@ -2,6 +2,9 @@ - Fixes changelog validation when reverting to a `NEXT` state. - Fixes multiplication of `--force` flag when publishing multiple packages. +- Adds minimum deployment target flags to `xcode-analyze` to allow + enforcing deprecation warning handling in advance of actually dropping + support for an OS version. ## 0.8.5 diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index 4298acb1c7e5..a81bf15477af 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -23,8 +23,20 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { super(packagesDir, processRunner: processRunner, platform: platform) { argParser.addFlag(platformIOS, help: 'Analyze iOS'); argParser.addFlag(platformMacOS, help: 'Analyze macOS'); + argParser.addOption(_minIOSVersionArg, + help: 'Sets the minimum iOS deployment version to use when compiling, ' + 'overriding the default minimum version. This can be used to find ' + 'deprecation warnings that will affect the plugin in the future.'); + argParser.addOption(_minMacOSVersionArg, + help: + 'Sets the minimum macOS deployment version to use when compiling, ' + 'overriding the default minimum version. This can be used to find ' + 'deprecation warnings that will affect the plugin in the future.'); } + static const String _minIOSVersionArg = 'ios-min-version'; + static const String _minMacOSVersionArg = 'macos-min-version'; + final Xcode _xcode; @override @@ -57,15 +69,24 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { return PackageResult.skip('Not implemented for target platform(s).'); } + final String minIOSVersion = getStringArg(_minIOSVersionArg); + final String minMacOSVersion = getStringArg(_minMacOSVersionArg); + final List failures = []; if (testIOS && !await _analyzePlugin(package, 'iOS', extraFlags: [ '-destination', - 'generic/platform=iOS Simulator' + 'generic/platform=iOS Simulator', + if (minIOSVersion.isNotEmpty) + 'IPHONEOS_DEPLOYMENT_TARGET=$minIOSVersion', ])) { failures.add('iOS'); } - if (testMacOS && !await _analyzePlugin(package, 'macOS')) { + if (testMacOS && + !await _analyzePlugin(package, 'macOS', extraFlags: [ + if (minMacOSVersion.isNotEmpty) + 'MACOSX_DEPLOYMENT_TARGET=$minMacOSVersion', + ])) { failures.add('macOS'); } diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index 51e8e3283295..dfc270891d8a 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -123,6 +123,47 @@ void main() { ])); }); + test('passes min iOS deployment version when requested', () async { + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformIOS: const PlatformDetails(PlatformSupport.inline) + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + final List output = await runCapturingPrint(runner, + ['xcode-analyze', '--ios', '--ios-min-version=14.0']); + + expect( + output, + containsAllInOrder([ + contains('Running for plugin'), + contains('plugin/example (iOS) passed analysis.') + ])); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + 'xcrun', + const [ + 'xcodebuild', + 'analyze', + '-workspace', + 'ios/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + '-destination', + 'generic/platform=iOS Simulator', + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + 'IOS_DEPLOYMENT_TARGET=14.0', + ], + pluginExampleDirectory.path), + ])); + }); + test('fails if xcrun fails', () async { createFakePlugin('plugin', packagesDir, platformSupport: { @@ -218,6 +259,41 @@ void main() { ])); }); + test('passes min macOS deployment version when requested', () async { + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformMacOS: const PlatformDetails(PlatformSupport.inline), + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + final List output = await runCapturingPrint(runner, + ['xcode-analyze', '--macos', '--macos-min-version=12.0']); + + expect(output, + contains(contains('plugin/example (macOS) passed analysis.'))); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + 'xcrun', + const [ + 'xcodebuild', + 'analyze', + '-workspace', + 'macos/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + 'MACOSX_DEPLOYMENT_VERSION=12.0', + ], + pluginExampleDirectory.path), + ])); + }); + test('fails if xcrun fails', () async { createFakePlugin('plugin', packagesDir, platformSupport: { From 7a4dcacc483c41d866b5ca71578f807f029e6b2d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 16 May 2022 14:01:08 -0400 Subject: [PATCH 2/4] Add CI --- .cirrus.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index eaaac8d7b5b5..f8f9633ec6a8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -334,6 +334,11 @@ task: - ./script/tool_runner.sh build-examples --ios xcode_analyze_script: - ./script/tool_runner.sh xcode-analyze --ios + xcode_analyze_deprecation_script: + # Ensure we don't accidentally introduce deprecated code. + # TODO(stuartmorgan): Update this to a newer version of iOS to get + # ahead of upcoming deprecations. + - ./script/tool_runner.sh xcode-analyze --ios --ios-min-version=11.0 native_test_script: - ./script/tool_runner.sh native-test --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest" drive_script: @@ -362,6 +367,9 @@ task: - ./script/tool_runner.sh build-examples --macos xcode_analyze_script: - ./script/tool_runner.sh xcode-analyze --macos + xcode_analyze_deprecation_script: + # Ensure we don't accidentally introduce deprecated code. + - ./script/tool_runner.sh xcode-analyze --macos --macos-min-version=12.3 native_test_script: - ./script/tool_runner.sh native-test --macos drive_script: From d75b4103eb95f4c62dcc9124557091a186fed1ff Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 17 May 2022 14:10:11 -0400 Subject: [PATCH 3/4] Suppress AppAuth warnings --- packages/google_sign_in/google_sign_in_ios/example/ios/Podfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/google_sign_in/google_sign_in_ios/example/ios/Podfile b/packages/google_sign_in/google_sign_in_ios/example/ios/Podfile index e577a3081fe8..b20e1ad2fca0 100644 --- a/packages/google_sign_in/google_sign_in_ios/example/ios/Podfile +++ b/packages/google_sign_in/google_sign_in_ios/example/ios/Podfile @@ -25,6 +25,9 @@ end require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) +# Suppress warnings from transitive dependencies that cause analysis to fail. +pod 'AppAuth', :inhibit_warnings => true + flutter_ios_podfile_setup target 'Runner' do From eb31ca76571c4c2c16cad4b51b311715ffde6bed Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 17 May 2022 15:02:21 -0400 Subject: [PATCH 4/4] Fix missed expectation mistakes --- script/tool/test/xcode_analyze_command_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index dfc270891d8a..418c695f295c 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -157,8 +157,8 @@ void main() { 'Debug', '-destination', 'generic/platform=iOS Simulator', + 'IPHONEOS_DEPLOYMENT_TARGET=14.0', 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', - 'IOS_DEPLOYMENT_TARGET=14.0', ], pluginExampleDirectory.path), ])); @@ -287,8 +287,8 @@ void main() { 'Runner', '-configuration', 'Debug', + 'MACOSX_DEPLOYMENT_TARGET=12.0', 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', - 'MACOSX_DEPLOYMENT_VERSION=12.0', ], pluginExampleDirectory.path), ]));