|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.IO; |
4 | 4 | using System.Linq; |
| 5 | +using System.Runtime.Serialization; |
5 | 6 | using System.Threading.Tasks; |
6 | 7 | using Claunia.PropertyList; |
7 | 8 | using DotNetCheck.Models; |
@@ -66,8 +67,27 @@ public override Task<DiagnosticResult> Examine(SharedState history) |
66 | 67 | new Solutions.XcodeEulaSolution()))); |
67 | 68 | } |
68 | 69 |
|
| 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 | + |
69 | 88 | // Selected version is good |
70 | 89 | ReportStatus($"Xcode.app ({selected.VersionString} {selected.BuildVersion})", Status.Ok); |
| 90 | + |
71 | 91 | return Task.FromResult(DiagnosticResult.Ok(this)); |
72 | 92 | } |
73 | 93 |
|
@@ -198,6 +218,21 @@ XCodeInfo GetXcodeInfo(string path, bool selected) |
198 | 218 | } |
199 | 219 | return null; |
200 | 220 | } |
| 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 | + } |
201 | 236 | } |
202 | 237 |
|
203 | 238 | public record XCodeInfo(NuGetVersion Version, string VersionString, string BuildVersion, string Path, bool Selected); |
|
0 commit comments