Skip to content

Commit

Permalink
Merge pull request #174 from unoplatform/gh170
Browse files Browse the repository at this point in the history
feat: Add check and solution for Xcode EULA
  • Loading branch information
jeromelaban authored Oct 3, 2023
2 parents 8b3b649 + 485a4a6 commit d29ffaf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions UnoCheck/Checkups/XCodeCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ public override Task<DiagnosticResult> 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));
Expand Down
17 changes: 17 additions & 0 deletions UnoCheck/Solutions/XcodeEulaSolution.cs
Original file line number Diff line number Diff line change
@@ -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" });
}
}
}

0 comments on commit d29ffaf

Please sign in to comment.