Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 76abf76

Browse files
[ci/tools] Add iOS/macOS analysis to catch deprecated code (#5778)
1 parent 07467dc commit 76abf76

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

.cirrus.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ task:
334334
- ./script/tool_runner.sh build-examples --ios
335335
xcode_analyze_script:
336336
- ./script/tool_runner.sh xcode-analyze --ios
337+
xcode_analyze_deprecation_script:
338+
# Ensure we don't accidentally introduce deprecated code.
339+
# TODO(stuartmorgan): Update this to a newer version of iOS to get
340+
# ahead of upcoming deprecations.
341+
- ./script/tool_runner.sh xcode-analyze --ios --ios-min-version=11.0
337342
native_test_script:
338343
- ./script/tool_runner.sh native-test --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
339344
drive_script:
@@ -362,6 +367,9 @@ task:
362367
- ./script/tool_runner.sh build-examples --macos
363368
xcode_analyze_script:
364369
- ./script/tool_runner.sh xcode-analyze --macos
370+
xcode_analyze_deprecation_script:
371+
# Ensure we don't accidentally introduce deprecated code.
372+
- ./script/tool_runner.sh xcode-analyze --macos --macos-min-version=12.3
365373
native_test_script:
366374
- ./script/tool_runner.sh native-test --macos
367375
drive_script:

packages/google_sign_in/google_sign_in_ios/example/ios/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ end
2525

2626
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
2727

28+
# Suppress warnings from transitive dependencies that cause analysis to fail.
29+
pod 'AppAuth', :inhibit_warnings => true
30+
2831
flutter_ios_podfile_setup
2932

3033
target 'Runner' do

script/tool/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- Fixes changelog validation when reverting to a `NEXT` state.
44
- Fixes multiplication of `--force` flag when publishing multiple packages.
5+
- Adds minimum deployment target flags to `xcode-analyze` to allow
6+
enforcing deprecation warning handling in advance of actually dropping
7+
support for an OS version.
58
- Checks for template boilerplate in `readme-check`.
69
- `readme-check` now validates example READMEs when present.
710

script/tool/lib/src/xcode_analyze_command.dart

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,20 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
2323
super(packagesDir, processRunner: processRunner, platform: platform) {
2424
argParser.addFlag(platformIOS, help: 'Analyze iOS');
2525
argParser.addFlag(platformMacOS, help: 'Analyze macOS');
26+
argParser.addOption(_minIOSVersionArg,
27+
help: 'Sets the minimum iOS deployment version to use when compiling, '
28+
'overriding the default minimum version. This can be used to find '
29+
'deprecation warnings that will affect the plugin in the future.');
30+
argParser.addOption(_minMacOSVersionArg,
31+
help:
32+
'Sets the minimum macOS deployment version to use when compiling, '
33+
'overriding the default minimum version. This can be used to find '
34+
'deprecation warnings that will affect the plugin in the future.');
2635
}
2736

37+
static const String _minIOSVersionArg = 'ios-min-version';
38+
static const String _minMacOSVersionArg = 'macos-min-version';
39+
2840
final Xcode _xcode;
2941

3042
@override
@@ -57,15 +69,24 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
5769
return PackageResult.skip('Not implemented for target platform(s).');
5870
}
5971

72+
final String minIOSVersion = getStringArg(_minIOSVersionArg);
73+
final String minMacOSVersion = getStringArg(_minMacOSVersionArg);
74+
6075
final List<String> failures = <String>[];
6176
if (testIOS &&
6277
!await _analyzePlugin(package, 'iOS', extraFlags: <String>[
6378
'-destination',
64-
'generic/platform=iOS Simulator'
79+
'generic/platform=iOS Simulator',
80+
if (minIOSVersion.isNotEmpty)
81+
'IPHONEOS_DEPLOYMENT_TARGET=$minIOSVersion',
6582
])) {
6683
failures.add('iOS');
6784
}
68-
if (testMacOS && !await _analyzePlugin(package, 'macOS')) {
85+
if (testMacOS &&
86+
!await _analyzePlugin(package, 'macOS', extraFlags: <String>[
87+
if (minMacOSVersion.isNotEmpty)
88+
'MACOSX_DEPLOYMENT_TARGET=$minMacOSVersion',
89+
])) {
6990
failures.add('macOS');
7091
}
7192

script/tool/test/xcode_analyze_command_test.dart

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,47 @@ void main() {
123123
]));
124124
});
125125

126+
test('passes min iOS deployment version when requested', () async {
127+
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
128+
platformSupport: <String, PlatformDetails>{
129+
platformIOS: const PlatformDetails(PlatformSupport.inline)
130+
});
131+
132+
final Directory pluginExampleDirectory = getExampleDir(plugin);
133+
134+
final List<String> output = await runCapturingPrint(runner,
135+
<String>['xcode-analyze', '--ios', '--ios-min-version=14.0']);
136+
137+
expect(
138+
output,
139+
containsAllInOrder(<Matcher>[
140+
contains('Running for plugin'),
141+
contains('plugin/example (iOS) passed analysis.')
142+
]));
143+
144+
expect(
145+
processRunner.recordedCalls,
146+
orderedEquals(<ProcessCall>[
147+
ProcessCall(
148+
'xcrun',
149+
const <String>[
150+
'xcodebuild',
151+
'analyze',
152+
'-workspace',
153+
'ios/Runner.xcworkspace',
154+
'-scheme',
155+
'Runner',
156+
'-configuration',
157+
'Debug',
158+
'-destination',
159+
'generic/platform=iOS Simulator',
160+
'IPHONEOS_DEPLOYMENT_TARGET=14.0',
161+
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
162+
],
163+
pluginExampleDirectory.path),
164+
]));
165+
});
166+
126167
test('fails if xcrun fails', () async {
127168
createFakePlugin('plugin', packagesDir,
128169
platformSupport: <String, PlatformDetails>{
@@ -218,6 +259,41 @@ void main() {
218259
]));
219260
});
220261

262+
test('passes min macOS deployment version when requested', () async {
263+
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
264+
platformSupport: <String, PlatformDetails>{
265+
platformMacOS: const PlatformDetails(PlatformSupport.inline),
266+
});
267+
268+
final Directory pluginExampleDirectory = getExampleDir(plugin);
269+
270+
final List<String> output = await runCapturingPrint(runner,
271+
<String>['xcode-analyze', '--macos', '--macos-min-version=12.0']);
272+
273+
expect(output,
274+
contains(contains('plugin/example (macOS) passed analysis.')));
275+
276+
expect(
277+
processRunner.recordedCalls,
278+
orderedEquals(<ProcessCall>[
279+
ProcessCall(
280+
'xcrun',
281+
const <String>[
282+
'xcodebuild',
283+
'analyze',
284+
'-workspace',
285+
'macos/Runner.xcworkspace',
286+
'-scheme',
287+
'Runner',
288+
'-configuration',
289+
'Debug',
290+
'MACOSX_DEPLOYMENT_TARGET=12.0',
291+
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
292+
],
293+
pluginExampleDirectory.path),
294+
]));
295+
});
296+
221297
test('fails if xcrun fails', () async {
222298
createFakePlugin('plugin', packagesDir,
223299
platformSupport: <String, PlatformDetails>{

0 commit comments

Comments
 (0)