Skip to content

Commit 84b38b8

Browse files
authored
Make LLDB check a warning instead of a failure (#164828)
We added LLDB file in flutter/flutter#164344. This adjusts it so if the LLDB file is missing it gives a warning rather than an error that fails the build. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 4fef40c commit 84b38b8

File tree

2 files changed

+39
-11
lines changed
  • packages/flutter_tools

2 files changed

+39
-11
lines changed

packages/flutter_tools/lib/src/build_system/targets/ios.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,13 @@ abstract class IosLLDBInit extends Target {
503503
// an error.
504504
final String? srcRoot = environment.defines[kSrcRoot];
505505
if (srcRoot == null) {
506-
throw MissingDefineException(kSdkRoot, name);
506+
environment.logger.printError('Failed to find $srcRoot');
507+
return;
507508
}
508509
final Directory xcodeProjectDir = environment.fileSystem.directory(srcRoot);
509510
if (!xcodeProjectDir.existsSync()) {
510-
throw Exception('Failed to find ${xcodeProjectDir.path}');
511+
environment.logger.printError('Failed to find ${xcodeProjectDir.path}');
512+
return;
511513
}
512514

513515
bool anyLLDBInitFound = false;
@@ -522,14 +524,20 @@ abstract class IosLLDBInit extends Target {
522524
if (!anyLLDBInitFound) {
523525
final FlutterProject flutterProject = FlutterProject.fromDirectory(environment.projectDir);
524526
if (flutterProject.isModule) {
525-
throwToolExit(
526-
'Debugging Flutter on new iOS versions requires an LLDB Init File. To '
527+
// We use print here to make sure Xcode adds the message to the build logs. See
528+
// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script
529+
// ignore: avoid_print
530+
print(
531+
'warning: Debugging Flutter on new iOS versions requires an LLDB Init File. To '
527532
'ensure debug mode works, please run "flutter build ios --config-only" '
528533
'in your Flutter project and follow the instructions to add the file.',
529534
);
530535
} else {
531-
throwToolExit(
532-
'Debugging Flutter on new iOS versions requires an LLDB Init File. To '
536+
// We use print here to make sure Xcode adds the message to the build logs. See
537+
// https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script
538+
// ignore: avoid_print
539+
print(
540+
'warning: Debugging Flutter on new iOS versions requires an LLDB Init File. To '
533541
'ensure debug mode works, please run "flutter build ios --config-only" '
534542
'in your Flutter project and automatically add the files.',
535543
);

packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:async';
6+
57
import 'package:file/memory.dart';
68
import 'package:file_testing/file_testing.dart';
79
import 'package:flutter_tools/src/artifacts.dart';
@@ -1155,7 +1157,7 @@ void main() {
11551157

11561158
group('DebugIosLLDBInit', () {
11571159
testUsingContext(
1158-
'throws error if missing LLDB Init File in all schemes',
1160+
'prints warning if missing LLDB Init File in all schemes',
11591161
() async {
11601162
const String projectPath = 'path/to/project';
11611163
fileSystem.directory(projectPath).createSync(recursive: true);
@@ -1165,11 +1167,12 @@ void main() {
11651167
environment.defines[kSrcRoot] = projectPath;
11661168
environment.defines[kTargetDeviceOSVersion] = '18.4.1';
11671169

1170+
final StringBuffer buffer = await capturedConsolePrint(() async {
1171+
await const DebugIosLLDBInit().build(environment);
1172+
});
11681173
expect(
1169-
const DebugIosLLDBInit().build(environment),
1170-
throwsToolExit(
1171-
message: 'Debugging Flutter on new iOS versions requires an LLDB Init File.',
1172-
),
1174+
buffer.toString(),
1175+
contains('warning: Debugging Flutter on new iOS versions requires an LLDB Init File.'),
11731176
);
11741177
},
11751178
overrides: <Type, Generator>{
@@ -1261,3 +1264,20 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
12611264
return XcodeProjectInfo(<String>[], <String>[], schemes, BufferLogger.test());
12621265
}
12631266
}
1267+
1268+
/// Capture console print events into a string buffer.
1269+
Future<StringBuffer> capturedConsolePrint(Future<void> Function() body) async {
1270+
final StringBuffer buffer = StringBuffer();
1271+
await runZoned<Future<void>>(
1272+
() async {
1273+
// Service the event loop.
1274+
await body();
1275+
},
1276+
zoneSpecification: ZoneSpecification(
1277+
print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
1278+
buffer.writeln(line);
1279+
},
1280+
),
1281+
);
1282+
return buffer;
1283+
}

0 commit comments

Comments
 (0)