3
3
// found in the LICENSE file.
4
4
5
5
import 'common/core.dart' ;
6
+ import 'common/flutter_command_utils.dart' ;
6
7
import 'common/output_utils.dart' ;
7
8
import 'common/package_looping_command.dart' ;
8
9
import 'common/plugin_utils.dart' ;
@@ -74,19 +75,21 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
74
75
75
76
final List <String > failures = < String > [];
76
77
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
+ ])) {
83
85
failures.add ('iOS' );
84
86
}
85
87
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
+ ])) {
90
93
failures.add ('macOS' );
91
94
}
92
95
@@ -101,22 +104,40 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
101
104
/// Analyzes [plugin] for [targetPlatform] , returning true if it passed analysis.
102
105
Future <bool > _analyzePlugin (
103
106
RepositoryPackage plugin,
104
- String targetPlatform, {
107
+ FlutterPlatform targetPlatform, {
105
108
List <String > extraFlags = const < String > [],
106
109
}) async {
110
+ final String platformString =
111
+ targetPlatform == FlutterPlatform .ios ? 'iOS' : 'macOS' ;
107
112
bool passing = true ;
108
113
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
+
109
130
// Running tests and static analyzer.
110
131
final String examplePath = getRelativePosixPath (example.directory,
111
132
from: plugin.directory.parent);
112
- print ('Running $targetPlatform tests and analyzer for $examplePath ...' );
133
+ print ('Running $platformString tests and analyzer for $examplePath ...' );
113
134
final int exitCode = await _xcode.runXcodeBuild (
114
135
example.directory,
115
- targetPlatform ,
136
+ platformString ,
116
137
// Clean before analyzing to remove cached swiftmodules from previous
117
138
// runs, which can cause conflicts.
118
139
actions: < String > ['clean' , 'analyze' ],
119
- workspace: '${targetPlatform .toLowerCase ()}/Runner.xcworkspace' ,
140
+ workspace: '${platformString .toLowerCase ()}/Runner.xcworkspace' ,
120
141
scheme: 'Runner' ,
121
142
configuration: 'Debug' ,
122
143
hostPlatform: platform,
@@ -126,9 +147,9 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
126
147
],
127
148
);
128
149
if (exitCode == 0 ) {
129
- printSuccess ('$examplePath ($targetPlatform ) passed analysis.' );
150
+ printSuccess ('$examplePath ($platformString ) passed analysis.' );
130
151
} else {
131
- printError ('$examplePath ($targetPlatform ) failed analysis.' );
152
+ printError ('$examplePath ($platformString ) failed analysis.' );
132
153
passing = false ;
133
154
}
134
155
}
0 commit comments