コード例 #1
0
        Task <XCodeInfo> GetInfo()
        {
            //Xcode 12.4
            //Build version 12D4e
            var r = ShellProcessRunner.Run("xcodebuild", "-version");

            var info = new XCodeInfo();

            foreach (var line in r.StandardOutput)
            {
                if (line.StartsWith("Xcode"))
                {
                    var vstr = line.Substring(5).Trim();
                    if (Version.TryParse(vstr, out var v))
                    {
                        info.Version = v;
                    }
                }
                else if (line.StartsWith("Build version"))
                {
                    info.Build = line.Substring(13)?.Trim();
                }
            }

            return(Task.FromResult(info));
        }
コード例 #2
0
        public override Task <DiagnosticResult> Examine(SharedState history)
        {
            var selected = GetSelectedXCode();

            if (selected.Version.IsCompatible(MinimumVersion, ExactVersion))
            {
                // Selected version is good
                ReportStatus($"Xcode.app ({VersionName})", Status.Ok);
                return(Task.FromResult(DiagnosticResult.Ok(this)));
            }

            XCodeInfo eligibleXcode = null;

            var xcodes = FindXCodeInstalls();

            foreach (var x in xcodes)
            {
                if (x.Version.IsCompatible(MinimumVersion, ExactVersion))
                {
                    eligibleXcode = x;
                    break;
                }
            }

            if (eligibleXcode != null)
            {
                // If this is the case, they need to run xcode-select -s
                ReportStatus($"No Xcode.app or an incompatible Xcode.app version is selected, but one was found at ({eligibleXcode.Path})", Status.Error);

                return(Task.FromResult(new DiagnosticResult(
                                           Status.Error,
                                           this,
                                           new Suggestion("Run xcode-select -s <Path>",
                                                          new Solutions.ActionSolution((sln, cancelToken) =>
                {
                    ShellProcessRunner.Run("xcode-select", "-s " + eligibleXcode.Path);
                    return Task.CompletedTask;
                })))));
            }

            ReportStatus($"Xcode.app ({VersionName}) not installed.", Status.Error);

            return(Task.FromResult(new DiagnosticResult(
                                       Status.Error,
                                       this,
                                       new Suggestion($"Download XCode {VersionName}"))));
        }