Unverified Commit c175cf87 authored by Victoria Ashworth's avatar Victoria Ashworth Committed by GitHub

Ignore macOS Cocoapods linting failure on DT_TOOLCHAIN_DIR error (#133588)

Xcode 15 introduced an [error](https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/issues/132980.

Tracking issue to upgrade Cocoapods when fix is in a release: https://github.com/flutter/flutter/issues/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)
parent dd1ee24f
......@@ -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
......@@ -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',
],
......@@ -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',
......@@ -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;
}
}
}
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment