Skip to content

Commit cfe6e25

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

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

UnoCheck/Checkups/XCodeCheckup.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
54
using System.Threading.Tasks;
65
using Claunia.PropertyList;
76
using DotNetCheck.Models;
@@ -66,8 +65,27 @@ public override Task<DiagnosticResult> Examine(SharedState history)
6665
new Solutions.XcodeEulaSolution())));
6766
}
6867

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

@@ -198,6 +216,21 @@ XCodeInfo GetXcodeInfo(string path, bool selected)
198216
}
199217
return null;
200218
}
219+
220+
static bool ValidateForiOSSDK(XCodeInfo selected)
221+
{
222+
var iphoneSimulatorSDKPath = Path.Combine(selected.Path, "Contents", "Developer", "Platforms", "iPhoneSimulator.platform", "Developer", "SDKs", "iPhoneSimulator.sdk");
223+
224+
if (Directory.Exists(iphoneSimulatorSDKPath))
225+
{
226+
return true;
227+
}
228+
229+
var r = ShellProcessRunner.Run("xcrun", "-sdk iphonesimulator --show-sdk-path");
230+
iphoneSimulatorSDKPath = r.GetOutput().Trim();
231+
232+
return Directory.Exists(iphoneSimulatorSDKPath);
233+
}
201234
}
202235

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

0 commit comments

Comments
 (0)