Skip to content

Commit 9047369

Browse files
committed
feat(iOS): check for SDK
1 parent 2265bc8 commit 9047369

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

UnoCheck/Checkups/XCodeCheckup.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Runtime.Serialization;
56
using System.Threading.Tasks;
67
using Claunia.PropertyList;
78
using DotNetCheck.Models;
@@ -66,8 +67,27 @@ public override Task<DiagnosticResult> Examine(SharedState history)
6667
new Solutions.XcodeEulaSolution())));
6768
}
6869

70+
//before returning we want to validate that the iOS SDK is installed
71+
if (!ValidateForiOSSDK(selected))
72+
{
73+
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);
74+
75+
Spectre.Console.AnsiConsole.MarkupLine("Open Xcode to complete the installation of the iOS SDK");
76+
77+
return Task.FromResult(new DiagnosticResult(
78+
Status.Error,
79+
this,
80+
new Suggestion("Run `open -a Xcode`",
81+
new Solutions.ActionSolution((sln, cancelToken) =>
82+
{
83+
ShellProcessRunner.Run("open", $"-a {selected.Path}");
84+
return Task.CompletedTask;
85+
}))));
86+
}
87+
6988
// Selected version is good
7089
ReportStatus($"Xcode.app ({selected.VersionString} {selected.BuildVersion})", Status.Ok);
90+
7191
return Task.FromResult(DiagnosticResult.Ok(this));
7292
}
7393

@@ -198,6 +218,21 @@ XCodeInfo GetXcodeInfo(string path, bool selected)
198218
}
199219
return null;
200220
}
221+
222+
static bool ValidateForiOSSDK(XCodeInfo selected)
223+
{
224+
var iphoneSimulatorSDKPath = Path.Combine(selected.Path, "Contents", "Developer", "Platforms", "iPhoneSimulator.platform", "Developer", "SDKs", "iPhoneSimulator.sdk");
225+
226+
if (Directory.Exists(iphoneSimulatorSDKPath))
227+
{
228+
return true;
229+
}
230+
231+
var r = ShellProcessRunner.Run("xcrun", "-sdk iphonesimulator --show-sdk-path");
232+
iphoneSimulatorSDKPath = r.GetOutput().Trim();
233+
234+
return Directory.Exists(iphoneSimulatorSDKPath);
235+
}
201236
}
202237

203238
public record XCodeInfo(NuGetVersion Version, string VersionString, string BuildVersion, string Path, bool Selected);

0 commit comments

Comments
 (0)