@@ -277,16 +277,41 @@ Future<XcodeBuildResult> buildXcodeProject({
277
277
);
278
278
}
279
279
280
+ final Status cleanStatus =
281
+ logger.startProgress ('Running Xcode clean...' , expectSlowOperation: true );
282
+ final RunResult cleanResult = await runAsync (
283
+ < String > [
284
+ '/usr/bin/env' ,
285
+ 'xcrun' ,
286
+ 'xcodebuild' ,
287
+ 'clean' ,
288
+ '-configuration' , configuration,
289
+ ],
290
+ workingDirectory: app.appDirectory,
291
+ );
292
+ cleanStatus.stop ();
293
+ if (cleanResult.exitCode != 0 ) {
294
+ throwToolExit ('Xcode failed to clean\n ${cleanResult .stderr }' );
295
+ }
296
+
280
297
final List <String > commands = < String > [
281
298
'/usr/bin/env' ,
282
299
'xcrun' ,
283
300
'xcodebuild' ,
284
- 'clean' ,
285
301
'build' ,
286
302
'-configuration' , configuration,
287
303
'ONLY_ACTIVE_ARCH=YES' ,
288
304
];
289
305
306
+ if (logger.isVerbose) {
307
+ // An environment variable to be passed to xcode_backend.sh determining
308
+ // whether to echo back executed commands.
309
+ commands.add ('VERBOSE_SCRIPT_LOGGING=YES' );
310
+ } else {
311
+ // This will print warnings and errors only.
312
+ commands.add ('-quiet' );
313
+ }
314
+
290
315
if (developmentTeam != null )
291
316
commands.add ('DEVELOPMENT_TEAM=$developmentTeam ' );
292
317
@@ -318,27 +343,28 @@ Future<XcodeBuildResult> buildXcodeProject({
318
343
);
319
344
}
320
345
321
- final Status status = logger.startProgress ('Running Xcode build...' , expectSlowOperation: true );
322
- final RunResult result = await runAsync (
346
+ final Status buildStatus =
347
+ logger.startProgress ('Running Xcode build...' , expectSlowOperation: true );
348
+ final RunResult buildResult = await runAsync (
323
349
commands,
324
350
workingDirectory: app.appDirectory,
325
351
allowReentrantFlutter: true
326
352
);
327
- status .stop ();
328
- if (result .exitCode != 0 ) {
353
+ buildStatus .stop ();
354
+ if (buildResult .exitCode != 0 ) {
329
355
printStatus ('Failed to build iOS app' );
330
- if (result .stderr.isNotEmpty) {
356
+ if (buildResult .stderr.isNotEmpty) {
331
357
printStatus ('Error output from Xcode build:\n ↳' );
332
- printStatus (result .stderr, indent: 4 );
358
+ printStatus (buildResult .stderr, indent: 4 );
333
359
}
334
- if (result .stdout.isNotEmpty) {
360
+ if (buildResult .stdout.isNotEmpty) {
335
361
printStatus ('Xcode\' s output:\n ↳' );
336
- printStatus (result .stdout, indent: 4 );
362
+ printStatus (buildResult .stdout, indent: 4 );
337
363
}
338
364
return new XcodeBuildResult (
339
365
success: false ,
340
- stdout: result .stdout,
341
- stderr: result .stderr,
366
+ stdout: buildResult .stdout,
367
+ stderr: buildResult .stderr,
342
368
xcodeBuildExecution: new XcodeBuildExecution (
343
369
commands,
344
370
app.appDirectory,
@@ -348,7 +374,7 @@ Future<XcodeBuildResult> buildXcodeProject({
348
374
} else {
349
375
// Look for 'clean build/<configuration>-<sdk>/Runner.app'.
350
376
final RegExp regexp = new RegExp (r' clean (.*\.app)$' , multiLine: true );
351
- final Match match = regexp.firstMatch (result .stdout);
377
+ final Match match = regexp.firstMatch (buildResult .stdout);
352
378
String outputDir;
353
379
if (match != null ) {
354
380
final String actualOutputDir = match.group (1 ).replaceAll ('\\ ' , ' ' );
0 commit comments