33// found in the LICENSE file.
44
55import 'common/core.dart' ;
6+ import 'common/flutter_command_utils.dart' ;
67import 'common/output_utils.dart' ;
78import 'common/package_looping_command.dart' ;
89import 'common/plugin_utils.dart' ;
@@ -74,19 +75,21 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
7475
7576 final List <String > failures = < String > [];
7677 if (testIOS &&
77- ! await _analyzePlugin (package, 'iOS' , extraFlags: < String > [
78- '-destination' ,
79- 'generic/platform=iOS Simulator' ,
80- if (minIOSVersion.isNotEmpty)
81- 'IPHONEOS_DEPLOYMENT_TARGET=$minIOSVersion ' ,
82- ])) {
78+ ! await _analyzePlugin (package, FlutterPlatform .ios,
79+ extraFlags: < String > [
80+ '-destination' ,
81+ 'generic/platform=iOS Simulator' ,
82+ if (minIOSVersion.isNotEmpty)
83+ 'IPHONEOS_DEPLOYMENT_TARGET=$minIOSVersion ' ,
84+ ])) {
8385 failures.add ('iOS' );
8486 }
8587 if (testMacOS &&
86- ! await _analyzePlugin (package, 'macOS' , extraFlags: < String > [
87- if (minMacOSVersion.isNotEmpty)
88- 'MACOSX_DEPLOYMENT_TARGET=$minMacOSVersion ' ,
89- ])) {
88+ ! await _analyzePlugin (package, FlutterPlatform .macos,
89+ extraFlags: < String > [
90+ if (minMacOSVersion.isNotEmpty)
91+ 'MACOSX_DEPLOYMENT_TARGET=$minMacOSVersion ' ,
92+ ])) {
9093 failures.add ('macOS' );
9194 }
9295
@@ -101,22 +104,40 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
101104 /// Analyzes [plugin] for [targetPlatform] , returning true if it passed analysis.
102105 Future <bool > _analyzePlugin (
103106 RepositoryPackage plugin,
104- String targetPlatform, {
107+ FlutterPlatform targetPlatform, {
105108 List <String > extraFlags = const < String > [],
106109 }) async {
110+ final String platformString =
111+ targetPlatform == FlutterPlatform .ios ? 'iOS' : 'macOS' ;
107112 bool passing = true ;
108113 for (final RepositoryPackage example in plugin.getExamples ()) {
114+ // Unconditionally re-run build with --debug --config-only, to ensure that
115+ // the project is in a debug state even if it was previously configured.
116+ print ('Running flutter build --config-only...' );
117+ final bool buildSuccess = await runConfigOnlyBuild (
118+ example,
119+ processRunner,
120+ platform,
121+ targetPlatform,
122+ buildDebug: true ,
123+ );
124+ if (! buildSuccess) {
125+ printError ('Unable to prepare native project files.' );
126+ passing = false ;
127+ continue ;
128+ }
129+
109130 // Running tests and static analyzer.
110131 final String examplePath = getRelativePosixPath (example.directory,
111132 from: plugin.directory.parent);
112- print ('Running $targetPlatform tests and analyzer for $examplePath ...' );
133+ print ('Running $platformString tests and analyzer for $examplePath ...' );
113134 final int exitCode = await _xcode.runXcodeBuild (
114135 example.directory,
115- targetPlatform ,
136+ platformString ,
116137 // Clean before analyzing to remove cached swiftmodules from previous
117138 // runs, which can cause conflicts.
118139 actions: < String > ['clean' , 'analyze' ],
119- workspace: '${targetPlatform .toLowerCase ()}/Runner.xcworkspace' ,
140+ workspace: '${platformString .toLowerCase ()}/Runner.xcworkspace' ,
120141 scheme: 'Runner' ,
121142 configuration: 'Debug' ,
122143 hostPlatform: platform,
@@ -126,9 +147,9 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
126147 ],
127148 );
128149 if (exitCode == 0 ) {
129- printSuccess ('$examplePath ($targetPlatform ) passed analysis.' );
150+ printSuccess ('$examplePath ($platformString ) passed analysis.' );
130151 } else {
131- printError ('$examplePath ($targetPlatform ) failed analysis.' );
152+ printError ('$examplePath ($platformString ) failed analysis.' );
132153 passing = false ;
133154 }
134155 }
0 commit comments