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