Handle xcrun failures via getXCodeSDK/getXCodeClang helpers

This commit is contained in:
Erwan Leboucher 2026-08-08 22:22:22 +02:00 committed by eleboucher
commit f3787d7f83
2 changed files with 17 additions and 15 deletions

View file

@ -1,11 +1,22 @@
import "dart:io";
Future<String> getXCodeSDK() async {
final result = await Process.run("xcrun", ["--show-sdk-path"]);
Future<String> _runXcrun(List<String> args, String errorContext) async {
final result = await Process.run("xcrun", args);
if (result.exitCode != 0) {
throw Exception("Failed to get XCode SDK\n${result.stderr}");
throw Exception("Failed to $errorContext\n${result.stderr}");
}
return result.stdout.trim();
return result.stdout.toString().trim();
}
Future<String> getXCodeSDK({String? sdkType}) => _runXcrun([
if (sdkType != null) ...["--sdk", sdkType],
"--show-sdk-path",
], "get XCode SDK");
Future<String> getXCodeClang({String? sdkType}) => _runXcrun([
if (sdkType != null) ...["--sdk", sdkType],
"-f",
"clang",
], "get XCode clang");