Skip to content

Commit c175cf8

Browse files
authored
Ignore macOS Cocoapods linting failure on DT_TOOLCHAIN_DIR error (flutter#133588)
Xcode 15 introduced an [error](flutter#132755) into Cocoapods when building macOS apps. When `pod lib lint` runs, it under the covers is building the app with `xcodebuild`, which is why this error occurs when linting. A fix has been made in Cocoapods, but is not in an official release so we can't upgrade Cocoapods yet. This is to temporarily ignore lint failure due to that error. Fixes flutter#132980. Tracking issue to upgrade Cocoapods when fix is in a release: flutter#133584 Since Xcode 15 isn't in CI, I tested it in a one-off led test: * [Pre-fix failure](https://chromium-swarm.appspot.com/task?id=6431f228ecf98e10) * [Post-fix success](https://chromium-swarm.appspot.com/task?id=645ba7ebdab97210)
1 parent dd1ee24 commit c175cf8

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

dev/devicelab/bin/tasks/plugin_lint_mac.dart

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ Future<void> main() async {
4646
);
4747

4848
final String macosintegrationTestPodspec = path.join(integrationTestPackage, 'integration_test_macos', 'macos', 'integration_test_macos.podspec');
49-
await exec(
50-
'pod',
49+
await _tryMacOSLint(
50+
macosintegrationTestPodspec,
5151
<String>[
52-
'lib',
53-
'lint',
54-
macosintegrationTestPodspec,
5552
'--verbose',
5653
// TODO(cyanglaz): remove allow-warnings when https://github.com/flutter/flutter/issues/125812 is fixed.
5754
// https://github.com/flutter/flutter/issues/125812
@@ -164,12 +161,9 @@ Future<void> main() async {
164161

165162
final String macOSPodspecPath = path.join(swiftPluginPath, 'macos', '$swiftPluginName.podspec');
166163
await inDirectory(tempDir, () async {
167-
await exec(
168-
'pod',
164+
await _tryMacOSLint(
165+
macOSPodspecPath,
169166
<String>[
170-
'lib',
171-
'lint',
172-
macOSPodspecPath,
173167
'--allow-warnings',
174168
'--verbose',
175169
],
@@ -179,12 +173,9 @@ Future<void> main() async {
179173
section('Lint Swift macOS podspec plugin as library');
180174

181175
await inDirectory(tempDir, () async {
182-
await exec(
183-
'pod',
176+
await _tryMacOSLint(
177+
macOSPodspecPath,
184178
<String>[
185-
'lib',
186-
'lint',
187-
macOSPodspecPath,
188179
'--allow-warnings',
189180
'--use-libraries',
190181
'--verbose',
@@ -533,3 +524,32 @@ void _validateMacOSPodfile(String appPath) {
533524
'macos',
534525
));
535526
}
527+
528+
Future<void> _tryMacOSLint(
529+
String podspecPath,
530+
List<String> extraArguments,
531+
) async {
532+
final StringBuffer lintStdout = StringBuffer();
533+
try {
534+
await eval(
535+
'pod',
536+
<String>[
537+
'lib',
538+
'lint',
539+
podspecPath,
540+
...extraArguments,
541+
],
542+
stdout: lintStdout,
543+
);
544+
} on BuildFailedError {
545+
// Temporarily ignore errors due to DT_TOOLCHAIN_DIR if it's the only error.
546+
// This error was introduced with Xcode 15. Fix was made in Cocoapods, but
547+
// is not in an official release yet.
548+
// TODO(vashworth): Stop ignoring when https://github.com/flutter/flutter/issues/133584 is complete.
549+
final String lintResult = lintStdout.toString();
550+
if (!(lintResult.contains('error: DT_TOOLCHAIN_DIR cannot be used to evaluate') &&
551+
lintResult.contains('did not pass validation, due to 1 error'))) {
552+
rethrow;
553+
}
554+
}
555+
}

dev/devicelab/lib/framework/utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,12 @@ Future<String> eval(
430430
Map<String, String>? environment,
431431
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
432432
String? workingDirectory,
433+
StringBuffer? stdout, // if not null, the stdout will be written here
433434
StringBuffer? stderr, // if not null, the stderr will be written here
434435
bool printStdout = true,
435436
bool printStderr = true,
436437
}) async {
437-
final StringBuffer output = StringBuffer();
438+
final StringBuffer output = stdout ?? StringBuffer();
438439
await _execute(
439440
executable,
440441
arguments,

0 commit comments

Comments
 (0)