Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion UnoCheck/Checkups/XCodeCheckup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Claunia.PropertyList;
using DotNetCheck.Models;
Expand Down Expand Up @@ -66,8 +65,27 @@ public override Task<DiagnosticResult> Examine(SharedState history)
new Solutions.XcodeEulaSolution())));
}

//before returning we want to validate that the iOS SDK is installed
if (!ValidateForiOSSDK(selected))
{
ReportStatus($"Xcode.app ({selected.VersionString} {selected.BuildVersion}) is installed, but missing the iOS SDK. Usually, this occurs after a recent Xcode install or update.", Status.Error);

Spectre.Console.AnsiConsole.MarkupLine("Open Xcode to complete the installation of the iOS SDK");

return Task.FromResult(new DiagnosticResult(
Status.Error,
this,
new Suggestion("Run `open -a Xcode`",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That suggestion will not work if copy/pasted into a terminal. IOW it won't start Xcode (no path) and, if fixed, it won't show the Component window where the SDK can be loaded.

We should implement the steps from https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components#Download-Xcode-components-from-the-command-line

so we download and install the SDK from uno-check

new Solutions.ActionSolution((sln, cancelToken) =>
{
ShellProcessRunner.Run("open", $"-a {selected.Path}");
return Task.CompletedTask;
}))));
}

// Selected version is good
ReportStatus($"Xcode.app ({selected.VersionString} {selected.BuildVersion})", Status.Ok);

return Task.FromResult(DiagnosticResult.Ok(this));
}

Expand Down Expand Up @@ -198,6 +216,21 @@ XCodeInfo GetXcodeInfo(string path, bool selected)
}
return null;
}

static bool ValidateForiOSSDK(XCodeInfo selected)
{
var iphoneSimulatorSDKPath = Path.Combine(selected.Path, "Contents", "Developer", "Platforms", "iPhoneSimulator.platform", "Developer", "SDKs", "iPhoneSimulator.sdk");

if (Directory.Exists(iphoneSimulatorSDKPath))
{
return true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you delete the iOS SDK (from Xcode Component's window) then the directory will still be present, so the check will pass but the SDK will be missing (at build time).

}

var r = ShellProcessRunner.Run("xcrun", "-sdk iphonesimulator --show-sdk-path");
iphoneSimulatorSDKPath = r.GetOutput().Trim();

return Directory.Exists(iphoneSimulatorSDKPath);
}
}

public record XCodeInfo(NuGetVersion Version, string VersionString, string BuildVersion, string Path, bool Selected);
Expand Down
Loading