Skip to content

Commit

Permalink
Ignore macOS Cocoapods linting failure on DT_TOOLCHAIN_DIR error (#13…
Browse files Browse the repository at this point in the history
…3588)

Xcode 15 introduced an [error](flutter/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/flutter#132980.

Tracking issue to upgrade Cocoapods when fix is in a release: flutter/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)
  • Loading branch information
vashworth authored Aug 31, 2023
1 parent dd1ee24 commit c175cf8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
50 changes: 35 additions & 15 deletions dev/devicelab/bin/tasks/plugin_lint_mac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ Future<void> main() async {
);

final String macosintegrationTestPodspec = path.join(integrationTestPackage, 'integration_test_macos', 'macos', 'integration_test_macos.podspec');
await exec(
'pod',
await _tryMacOSLint(
macosintegrationTestPodspec,
<String>[
'lib',
'lint',
macosintegrationTestPodspec,
'--verbose',
// TODO(cyanglaz): remove allow-warnings when https://github.com/flutter/flutter/issues/125812 is fixed.
// https://github.com/flutter/flutter/issues/125812
Expand Down Expand Up @@ -164,12 +161,9 @@ Future<void> main() async {

final String macOSPodspecPath = path.join(swiftPluginPath, 'macos', '$swiftPluginName.podspec');
await inDirectory(tempDir, () async {
await exec(
'pod',
await _tryMacOSLint(
macOSPodspecPath,
<String>[
'lib',
'lint',
macOSPodspecPath,
'--allow-warnings',
'--verbose',
],
Expand All @@ -179,12 +173,9 @@ Future<void> main() async {
section('Lint Swift macOS podspec plugin as library');

await inDirectory(tempDir, () async {
await exec(
'pod',
await _tryMacOSLint(
macOSPodspecPath,
<String>[
'lib',
'lint',
macOSPodspecPath,
'--allow-warnings',
'--use-libraries',
'--verbose',
Expand Down Expand Up @@ -533,3 +524,32 @@ void _validateMacOSPodfile(String appPath) {
'macos',
));
}

Future<void> _tryMacOSLint(
String podspecPath,
List<String> extraArguments,
) async {
final StringBuffer lintStdout = StringBuffer();
try {
await eval(
'pod',
<String>[
'lib',
'lint',
podspecPath,
...extraArguments,
],
stdout: lintStdout,
);
} on BuildFailedError {
// Temporarily ignore errors due to DT_TOOLCHAIN_DIR if it's the only error.
// This error was introduced with Xcode 15. Fix was made in Cocoapods, but
// is not in an official release yet.
// TODO(vashworth): Stop ignoring when https://github.com/flutter/flutter/issues/133584 is complete.
final String lintResult = lintStdout.toString();
if (!(lintResult.contains('error: DT_TOOLCHAIN_DIR cannot be used to evaluate') &&
lintResult.contains('did not pass validation, due to 1 error'))) {
rethrow;
}
}
}
3 changes: 2 additions & 1 deletion dev/devicelab/lib/framework/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,12 @@ Future<String> eval(
Map<String, String>? environment,
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
String? workingDirectory,
StringBuffer? stdout, // if not null, the stdout will be written here
StringBuffer? stderr, // if not null, the stderr will be written here
bool printStdout = true,
bool printStderr = true,
}) async {
final StringBuffer output = StringBuffer();
final StringBuffer output = stdout ?? StringBuffer();
await _execute(
executable,
arguments,
Expand Down

0 comments on commit c175cf8

Please sign in to comment.