Ejemplo n.º 1
0
        void Init()
        {
            string currentLocation = IsInstalled ? Path.Combine(BinDir, "mtouch") : null;

            IsInstalled = false;
            if (string.IsNullOrEmpty(SdkDir))
            {
                foreach (var loc in DefaultLocations)
                {
                    if (IsInstalled = ValidateSdkLocation(loc, out hasUsrSubdir))
                    {
                        SdkDir = loc;
                        break;
                    }
                }
            }
            else
            {
                IsInstalled = ValidateSdkLocation(SdkDir, out hasUsrSubdir);
            }

            string mtouch = null;

            if (IsInstalled)
            {
                mtouch         = Path.Combine(BinDir, "mtouch");
                lastMTExeWrite = File.GetLastWriteTime(mtouch);
                Version        = ReadVersion();

                if (Version.CompareTo(IPhoneSdkVersion.V6_2) >= 0)
                {
                    LoggingService.LogInfo("Found Xamarin.iOS, version {0}.", Version);
                }
                else
                {
                    LoggingService.LogInfo("Found unsupported Xamarin.iOS, version {0}.", Version);
                    Version     = new IPhoneSdkVersion();
                    IsInstalled = false;
                }

                AnalyticsService.ReportContextProperty("XS.Core.SDK.iOS.Version", Version.ToString());
            }
            else
            {
                lastMTExeWrite = DateTime.MinValue;
                Version        = new IPhoneSdkVersion();
                LoggingService.LogInfo("Xamarin.iOS not installed. Can't find mtouch.");

                AnalyticsService.ReportContextProperty("XS.Core.SDK.iOS.Version", string.Empty);
            }

            if (Changed != null && currentLocation != mtouch)
            {
                Changed(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        void Init()
        {
            string currentLocation = IsInstalled ? MmpPath : null;

            IsInstalled = false;

            FrameworkDirectory = "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current";
            var envFrameworkDir = Environment.GetEnvironmentVariable("XAMMAC_FRAMEWORK_PATH");

            if (envFrameworkDir != null && Directory.Exists(envFrameworkDir))
            {
                FrameworkDirectory = envFrameworkDir;
            }

            var versionPath = Path.Combine(FrameworkDirectory, "Version");

            if (File.Exists(versionPath))
            {
                Version = ReadVersion(versionPath);
                lastWriteTimes [versionPath] = File.GetLastWriteTimeUtc(versionPath);
            }
            else
            {
                NotInstalled(versionPath, error: false);
                AnalyticsService.ReportContextProperty("XS.Core.SDK.Mac.Version", string.Empty);
                return;
            }

            var paths = Version >= new MacOSXSdkVersion(1, 9, 0)
                                ? Detect2x()
                                : Detect1x();

            foreach (var path in paths)
            {
                if (!File.Exists(path))
                {
                    NotInstalled(path);
                    return;
                }

                lastWriteTimes [path] = File.GetLastWriteTimeUtc(path);
            }

            IsInstalled = true;
            LoggingService.LogInfo("Found Xamarin.Mac, version {0}.", Version);
            AnalyticsService.ReportContextProperty("XS.Core.SDK.Mac.Version", Version.ToString());

            if (Changed != null && currentLocation != MmpPath)
            {
                Changed(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 3
0
        static void Init()
        {
            string devroot = null, vplist = null, xcode = null;
            bool   foundSdk = false;

            SetInvalid();

            DeveloperRoot = Environment.GetEnvironmentVariable("MD_APPLE_SDK_ROOT");
            if (string.IsNullOrEmpty(DeveloperRoot))
            {
                DeveloperRoot = GetConfiguredSdkLocation();

                if (string.IsNullOrEmpty(DeveloperRoot) && File.Exists("/usr/bin/xcode-select"))
                {
                    var startInfo = new ProcessStartInfo("/usr/bin/xcode-select", "--print-path");
                    startInfo.RedirectStandardOutput = true;
                    startInfo.UseShellExecute        = false;

                    var process = new Process();
                    var stdout  = string.Empty;

                    try {
                        process.StartInfo           = startInfo;
                        process.OutputDataReceived += (sender, e) => stdout += e.Data;
                        process.Start();
                        process.WaitForExit();
                    } catch (Win32Exception) {
                        stdout = string.Empty;
                    }

                    stdout = stdout.Trim();

                    if (!string.IsNullOrEmpty(stdout) && Directory.Exists(stdout))
                    {
                        if (stdout.EndsWith("/Contents/Developer", StringComparison.Ordinal))
                        {
                            stdout = stdout.Substring(0, stdout.Length - "/Contents/Developer".Length);
                        }

                        DeveloperRoot = stdout;
                    }
                }
            }

            if (string.IsNullOrEmpty(DeveloperRoot))
            {
                foreach (var v in DefaultRoots)
                {
                    if (ValidateSdkLocation(v, out xcode, out vplist, out devroot))
                    {
                        foundSdk = true;
                        break;
                    }

                    LoggingService.LogInfo("A valid Xcode installation was not found at '{0}'", v);
                }
            }
            else if (!ValidateSdkLocation(DeveloperRoot, out xcode, out vplist, out devroot))
            {
                LoggingService.LogError("A valid Xcode installation was not found at the configured location: '{0}'", DeveloperRoot);
                SetInvalid();
                return;
            }
            else
            {
                foundSdk = true;
            }

            if (foundSdk)
            {
                XcodePath                 = xcode;
                DeveloperRoot             = devroot;
                DeveloperRootVersionPlist = vplist;
            }
            else
            {
                SetInvalid();
                return;
            }

            try {
                var plist = Path.Combine(XcodePath, "Contents", "Info.plist");

                if (!File.Exists(plist))
                {
                    SetInvalid();
                    return;
                }

                lastWritten = File.GetLastWriteTime(plist);

                XcodeVersion  = new Version(3, 2, 6);
                XcodeRevision = "0";

                // DTXCode was introduced after xcode 3.2.6 so it may not exist
                var dict = PDictionary.FromFile(plist);

                PString value;
                if (dict.TryGetValue("DTXcode", out value))
                {
                    DTXcode = value.Value;
                }

                if (dict.TryGetValue("CFBundleShortVersionString", out value))
                {
                    XcodeVersion = Version.Parse(value.Value);
                }

                if (dict.TryGetValue("CFBundleVersion", out value))
                {
                    XcodeRevision = value.Value;
                }

                LoggingService.LogInfo("Found Xcode, version {0} ({1}).", XcodeVersion, XcodeRevision);
                AnalyticsService.ReportContextProperty("XS.Core.SDK.Xcode.Version", XcodeVersion.ToString());
                IsValid = true;
            } catch (Exception ex) {
                LoggingService.LogError("Error loading Xcode information for prefix '" + DeveloperRoot + "'", ex);
                SetInvalid();
            }
        }
Ejemplo n.º 4
0
        void Init()
        {
            string currentLocation = IsInstalled ? Path.Combine(BinDir, "mtouch") : null;

            IsInstalled = false;
            versions    = null;

            if (string.IsNullOrEmpty(SdkDir))
            {
                foreach (var loc in DefaultLocations)
                {
                    if (IsInstalled = ValidateSdkLocation(loc, out hasUsrSubdir))
                    {
                        SdkDir = loc;
                        break;
                    }
                }
            }
            else
            {
                IsInstalled = ValidateSdkLocation(SdkDir, out hasUsrSubdir);
            }

            string mtouch = null;

            if (IsInstalled)
            {
                mtouch         = Path.Combine(BinDir, "mtouch");
                lastMTExeWrite = File.GetLastWriteTime(mtouch);
                Version        = ReadVersion();

                // Note: We require 10.4 for the bundled mlaunch (and Versions.plist, although we have a handy fallback if that file is missing)
                if (Version.CompareTo(IPhoneSdkVersion.V10_4) >= 0)
                {
                    LoggingService.LogInfo("Found Xamarin.iOS, version {0}.", Version);

                    var path = Path.Combine(SdkDir, "Versions.plist");
                    if (File.Exists(path))
                    {
                        try {
                            versions = PDictionary.FromFile(path);
                        } catch {
                            LoggingService.LogWarning("Xamarin.iOS installation is corrupt: invalid Versions.plist.");
                        }
                    }

                    if (versions == null)
                    {
                        versions = CreateDefaultVersionsPlist();
                    }
                }
                else
                {
                    LoggingService.LogInfo("Found unsupported Xamarin.iOS, version {0}.", Version);
                    Version     = new IPhoneSdkVersion();
                    versions    = new PDictionary();
                    IsInstalled = false;
                }

                AnalyticsService.ReportContextProperty("XS.Core.SDK.iOS.Version", Version.ToString());
            }
            else
            {
                lastMTExeWrite = DateTime.MinValue;
                Version        = new IPhoneSdkVersion();
                versions       = new PDictionary();

                LoggingService.LogInfo("Xamarin.iOS not installed. Can't find mtouch.");

                AnalyticsService.ReportContextProperty("XS.Core.SDK.iOS.Version", string.Empty);
            }

            if (Changed != null && currentLocation != mtouch)
            {
                Changed(this, EventArgs.Empty);
            }
        }