-
Notifications
You must be signed in to change notification settings - Fork 22
feat(iOS): check for SDK #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
@@ -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`", | ||
| 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)); | ||
| } | ||
|
|
||
|
|
@@ -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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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