diff --git a/UnoCheck/Checkups/XCodeCheckup.cs b/UnoCheck/Checkups/XCodeCheckup.cs index c4397e91..ef5a9359 100644 --- a/UnoCheck/Checkups/XCodeCheckup.cs +++ b/UnoCheck/Checkups/XCodeCheckup.cs @@ -48,6 +48,24 @@ public override Task Examine(SharedState history) if (selected is not null && selected.Version.IsCompatible(MinimumVersion, ExactVersion)) { + // customize runner options so the license can be displayed + var options = new ShellProcessRunnerOptions("xcodebuild", "") + { + RedirectOutput = Util.CI + }; + var runner = new ShellProcessRunner(options); + var result = runner.WaitForExit(); + // Check if user requires EULA to be accepted + if (result.ExitCode == 69) + { + Spectre.Console.AnsiConsole.MarkupLine("[bold red]By fixing this you are accepting the license agreement.[/]"); + return Task.FromResult(new DiagnosticResult( + Status.Error, + this, + new Suggestion("Run `sudo xcodebuild -license accept`", + new Solutions.XcodeEulaSolution()))); + } + // Selected version is good ReportStatus($"Xcode.app ({VersionName})", Status.Ok); return Task.FromResult(DiagnosticResult.Ok(this)); diff --git a/UnoCheck/Solutions/XcodeEulaSolution.cs b/UnoCheck/Solutions/XcodeEulaSolution.cs new file mode 100644 index 00000000..0e726715 --- /dev/null +++ b/UnoCheck/Solutions/XcodeEulaSolution.cs @@ -0,0 +1,17 @@ +using DotNetCheck.Models; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace DotNetCheck.Solutions +{ + internal class XcodeEulaSolution : Solution + { + public override async Task Implement(SharedState sharedState, CancellationToken cancellationToken) + { + await base.Implement(sharedState, cancellationToken); + + _ = await Util.WrapShellCommandWithSudo("xcodebuild", new[] { "-license", "accept" }); + } + } +} \ No newline at end of file