Example #1
0
        public override bool Execute()
        {
            PDictionary plist;

            Log.LogTaskName("CompileAppManifest");
            Log.LogTaskProperty("AppBundleName", AppBundleName);
            Log.LogTaskProperty("AppBundleDir", AppBundleDir);
            Log.LogTaskProperty("AppManifest", AppManifest);
            Log.LogTaskProperty("Architecture", Architecture);
            Log.LogTaskProperty("AssemblyName", AssemblyName);
            Log.LogTaskProperty("BundleIdentifier", BundleIdentifier);
            Log.LogTaskProperty("DefaultSdkVersion", DefaultSdkVersion);
            Log.LogTaskProperty("IsAppExtension", IsAppExtension);
            Log.LogTaskProperty("IsWatchApp", IsWatchApp);
            Log.LogTaskProperty("IsWatchExtension", IsWatchExtension);
            Log.LogTaskProperty("PartialAppManifests", PartialAppManifests);
            Log.LogTaskProperty("ResourceRules", ResourceRules);
            Log.LogTaskProperty("SdkPlatform", SdkPlatform);
            Log.LogTaskProperty("SdkIsSimulator", SdkIsSimulator);
            Log.LogTaskProperty("TargetFrameworkIdentifier", TargetFrameworkIdentifier);

            try {
                plist = PDictionary.FromFile(AppManifest);
            } catch (Exception ex) {
                LogAppManifestError("Error loading '{0}': {1}", AppManifest, ex.Message);
                return(false);
            }

            sdkVersion = IPhoneSdkVersion.Parse(DefaultSdkVersion);
            var text = plist.GetMinimumOSVersion();

            if (string.IsNullOrEmpty(text))
            {
                minimumOSVersion = sdkVersion;
            }
            else if (!IPhoneSdkVersion.TryParse(text, out minimumOSVersion))
            {
                LogAppManifestError("Could not parse MinimumOSVersion value '{0}'", text);
                return(false);
            }

            switch (Framework)
            {
            case PlatformFramework.iOS:
                IsIOS = true;
                break;

            case PlatformFramework.WatchOS:
                break;

            case PlatformFramework.TVOS:
                break;

            default:
                throw new InvalidOperationException(string.Format("Invalid framework: {0}", Framework));
            }

            return(Compile(plist));
        }
Example #2
0
        public override bool Execute()
        {
            var currentSdk = IPhoneSdks.GetSdk(TargetFrameworkMoniker);
            IPhoneSdkVersion version;
            string           sdk_path;

            if (IsWatchFramework)
            {
                if (!IPhoneSdkVersion.TryParse(SdkVersion, out version))
                {
                    Log.LogError(MSBStrings.E0066, SdkVersion);
                    return(false);
                }

                version  = currentSdk.GetClosestInstalledSdk(version, false);
                sdk_path = currentSdk.GetSdkPath(version, SdkIsSimulator);
            }
            else
            {
                if (AppleSdkSettings.XcodeVersion.Major >= 10)
                {
                    Log.LogError(MSBStrings.E0067);
                    return(false);
                }
                if (!(AppleSdkSettings.XcodeVersion.Major > 6 || (AppleSdkSettings.XcodeVersion.Major == 6 && AppleSdkSettings.XcodeVersion.Minor >= 2)))
                {
                    Log.LogError(MSBStrings.E0068);
                    return(false);
                }

                if (!IPhoneSdkVersion.TryParse(SdkVersion, out version))
                {
                    Log.LogError(MSBStrings.E0066, SdkVersion);
                    return(false);
                }

                if (version < IPhoneSdkVersion.V8_2)
                {
                    Log.LogError(MSBStrings.E0069, version);
                    return(false);
                }

                version  = currentSdk.GetClosestInstalledSdk(version, false);
                sdk_path = currentSdk.GetSdkPath(version, SdkIsSimulator);
            }

            NativeWatchApp = Path.Combine(sdk_path, "Library", "Application Support", "WatchKit", "WK");
            if (File.Exists(NativeWatchApp))
            {
                return(true);
            }

            Log.LogError(MSBStrings.E0070);

            return(false);
        }
Example #3
0
        public override bool Execute()
        {
            var currentSdk = IPhoneSdks.GetSdk(TargetFrameworkIdentifier);
            IPhoneSdkVersion version;
            string           sdk_path;

            if (IsWatchFramework)
            {
                if (!IPhoneSdkVersion.TryParse(SdkVersion, out version))
                {
                    Log.LogError("Failed to parse SdkVersion '{0}'.", SdkVersion);
                    return(false);
                }

                version  = currentSdk.GetClosestInstalledSdk(version, false);
                sdk_path = currentSdk.GetSdkPath(version, SdkIsSimulator);
            }
            else
            {
                if (AppleSdkSettings.XcodeVersion.Major >= 10)
                {
                    Log.LogError("Xcode 10 does not support watchOS 1 apps. Either upgrade to watchOS 2 apps, or use an older version of Xcode.");
                    return(false);
                }
                if (!(AppleSdkSettings.XcodeVersion.Major > 6 || (AppleSdkSettings.XcodeVersion.Major == 6 && AppleSdkSettings.XcodeVersion.Minor >= 2)))
                {
                    Log.LogError("An installation of Xcode >= 6.2 is required to build WatchKit applications.");
                    return(false);
                }

                if (!IPhoneSdkVersion.TryParse(SdkVersion, out version))
                {
                    Log.LogError("Failed to parse SdkVersion '{0}'.", SdkVersion);
                    return(false);
                }

                if (version < IPhoneSdkVersion.V8_2)
                {
                    Log.LogError("iOS {0} does not support WatchKit.", version);
                    return(false);
                }

                version  = currentSdk.GetClosestInstalledSdk(version, false);
                sdk_path = currentSdk.GetSdkPath(version, SdkIsSimulator);
            }

            NativeWatchApp = Path.Combine(sdk_path, "Library", "Application Support", "WatchKit", "WK");
            if (File.Exists(NativeWatchApp))
            {
                return(true);
            }

            Log.LogError("Failed to locate the WatchKit launcher in the Xcode app bundle.");

            return(false);
        }
Example #4
0
        public override bool Execute()
        {
            PDictionary plist;
            PString     value;

            try {
                plist = PDictionary.FromFile(AppManifest.ItemSpec);
            } catch (Exception ex) {
                Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not load Info.plist: {0}", ex.Message);
                return(false);
            }

//			deviceType = plist.GetUIDeviceFamily ();

            if (plist.TryGetValue(ManifestKeys.MinimumOSVersion, out value))
            {
                if (!IPhoneSdkVersion.TryParse(value.Value, out minimumOSVersion))
                {
                    Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not parse MinimumOSVersion '{0}'", value);
                    return(false);
                }
            }
            else
            {
                switch (Framework)
                {
                case PlatformFramework.iOS:
                    IPhoneSdkVersion sdkVersion;
                    if (!IPhoneSdkVersion.TryParse(SdkVersion, out sdkVersion))
                    {
                        Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not parse SdkVersion '{0}'", SdkVersion);
                        return(false);
                    }

                    minimumOSVersion = sdkVersion;
                    break;

                case PlatformFramework.WatchOS:
                case PlatformFramework.TVOS:
                    minimumOSVersion = IPhoneSdkVersion.UseDefault;
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Invalid framework: {0}", Framework));
                }
            }

            Directory.CreateDirectory(AppBundleDir);

            var result = base.Execute();

            CopiedFrameworks = GetCopiedFrameworks();

            return(result);
        }
        public override bool Execute()
        {
            PDictionary plist;

            try {
                plist = PDictionary.FromFile(AppManifest);
            } catch (Exception ex) {
                LogAppManifestError("Error loading '{0}': {1}", AppManifest, ex.Message);
                return(false);
            }

            sdkVersion = IPhoneSdkVersion.Parse(DefaultSdkVersion);
            var text = plist.GetMinimumOSVersion();

            if (string.IsNullOrEmpty(text))
            {
                minimumOSVersion = sdkVersion;
            }
            else if (!IPhoneSdkVersion.TryParse(text, out minimumOSVersion))
            {
                LogAppManifestError("Could not parse MinimumOSVersion value '{0}'", text);
                return(false);
            }

            switch (Framework)
            {
            case PlatformFramework.iOS:
                IsIOS = true;
                break;

            case PlatformFramework.WatchOS:
                break;

            case PlatformFramework.TVOS:
                break;

            default:
                throw new InvalidOperationException(string.Format("Invalid framework: {0}", Framework));
            }

            if (!string.IsNullOrEmpty(TargetArchitectures) && !Enum.TryParse(TargetArchitectures, out architectures))
            {
                LogAppManifestError("Could not parse TargetArchitectures '{0}'", TargetArchitectures);
                return(false);
            }

            return(Compile(plist));
        }
        public override bool Execute()
        {
            PDictionary plist;

            try {
                plist = PDictionary.FromFile(AppManifest);
            } catch (Exception ex) {
                LogAppManifestError(MSBStrings.E0010, AppManifest, ex.Message);
                return(false);
            }

            sdkVersion = IPhoneSdkVersion.Parse(DefaultSdkVersion);
            var text = plist.GetMinimumOSVersion();

            if (string.IsNullOrEmpty(text))
            {
                minimumOSVersion = sdkVersion;
            }
            else if (!IPhoneSdkVersion.TryParse(text, out minimumOSVersion))
            {
                LogAppManifestError(MSBStrings.E0011, text);
                return(false);
            }

            switch (Platform)
            {
            case ApplePlatform.iOS:
                IsIOS = true;
                break;

            case ApplePlatform.WatchOS:
                break;

            case ApplePlatform.TVOS:
                break;

            default:
                throw new InvalidOperationException(string.Format("Invalid platform: {0}", Platform));
            }

            if (!string.IsNullOrEmpty(TargetArchitectures) && !Enum.TryParse(TargetArchitectures, out architectures))
            {
                LogAppManifestError(MSBStrings.E0012, TargetArchitectures);
                return(false);
            }

            return(Compile(plist));
        }
Example #7
0
        public override bool Execute()
        {
            PDictionary plist;
            PString     value;

            Log.LogTaskName("MTouch");
            Log.LogTaskProperty("AppBundleDir", AppBundleDir);
            Log.LogTaskProperty("AppExtensionReferences", AppExtensionReferences);
            Log.LogTaskProperty("AppManifest", AppManifest);
            Log.LogTaskProperty("Architectures", Architectures);
            Log.LogTaskProperty("ArchiveSymbols", ArchiveSymbols);
            Log.LogTaskProperty("BitcodeEnabled", EnableBitcode);
            Log.LogTaskProperty("CompiledEntitlements", CompiledEntitlements);
            Log.LogTaskProperty("Debug", Debug);
            Log.LogTaskProperty("EnableGenericValueTypeSharing", EnableGenericValueTypeSharing);
            Log.LogTaskProperty("Entitlements", Entitlements);
            Log.LogTaskProperty("ExecutableName", ExecutableName);
            Log.LogTaskProperty("ExtraArgs", ExtraArgs);
            Log.LogTaskProperty("FastDev", FastDev);
            Log.LogTaskProperty("HttpClientHandler", HttpClientHandler);
            Log.LogTaskProperty("I18n", I18n);
            Log.LogTaskProperty("IntermediateOutputPath", IntermediateOutputPath);
            Log.LogTaskProperty("IsAppExtension", IsAppExtension);
            Log.LogTaskProperty("LinkerDumpDependencies", LinkerDumpDependencies);
            Log.LogTaskProperty("LinkMode", LinkMode);
            Log.LogTaskProperty("MainAssembly", MainAssembly);
            Log.LogTaskProperty("NativeReferences", NativeReferences);
            Log.LogTaskProperty("OutputPath", OutputPath);
            Log.LogTaskProperty("Profiling", Profiling);
            Log.LogTaskProperty("ProjectDir", ProjectDir);
            Log.LogTaskProperty("References", References);
            Log.LogTaskProperty("SdkIsSimulator", SdkIsSimulator);
            Log.LogTaskProperty("SdkRoot", SdkRoot);
            Log.LogTaskProperty("SdkVersion", SdkVersion);
            Log.LogTaskProperty("SymbolsList", SymbolsList);
            Log.LogTaskProperty("TargetFrameworkIdentifier", TargetFrameworkIdentifier);
            Log.LogTaskProperty("TLSProvider", TLSProvider);
            Log.LogTaskProperty("UseFloat32", UseFloat32);
            Log.LogTaskProperty("UseLlvm", UseLlvm);
            Log.LogTaskProperty("UseThumb", UseThumb);
            Log.LogTaskProperty("Verbosity", Verbosity.ToString());

            try {
                plist = PDictionary.FromFile(AppManifest.ItemSpec);
            } catch (Exception ex) {
                Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not load Info.plist: {0}", ex.Message);
                return(false);
            }

//			deviceType = plist.GetUIDeviceFamily ();

            if (plist.TryGetValue(ManifestKeys.MinimumOSVersion, out value))
            {
                if (!IPhoneSdkVersion.TryParse(value.Value, out minimumOSVersion))
                {
                    Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not parse MinimumOSVersion '{0}'", value);
                    return(false);
                }
            }
            else
            {
                switch (Framework)
                {
                case PlatformFramework.iOS:
                    if (IsUnified)
                    {
                        IPhoneSdkVersion sdkVersion;
                        if (!IPhoneSdkVersion.TryParse(SdkVersion, out sdkVersion))
                        {
                            Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not parse SdkVersion '{0}'", SdkVersion);
                            return(false);
                        }

                        minimumOSVersion = sdkVersion;
                    }
                    else
                    {
                        minimumOSVersion = IPhoneSdkVersion.V5_1_1;
                    }
                    break;

                case PlatformFramework.WatchOS:
                case PlatformFramework.TVOS:
                    minimumOSVersion = IPhoneSdkVersion.UseDefault;
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Invalid framework: {0}", Framework));
                }
            }

            Directory.CreateDirectory(AppBundleDir);

            var mtouchExecution = base.Execute();

            try {
                var nativeLibrariesPath = Directory.EnumerateFiles(AppBundleDir, "*.dylib", SearchOption.AllDirectories);
                var nativeLibraryItems  = new List <ITaskItem> ();

                foreach (var nativeLibrary in nativeLibrariesPath)
                {
                    nativeLibraryItems.Add(new TaskItem(nativeLibrary));
                }

                NativeLibraries = nativeLibraryItems.ToArray();
            } catch (Exception ex) {
                Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Could not get native libraries: {0}", ex.Message);
                return(false);
            }

            return(mtouchExecution);
        }
Example #8
0
        public override bool Execute()
        {
            PDictionary plist;
            PString     value;

            try {
                plist = PDictionary.FromFile(AppManifest.ItemSpec);
            } catch (Exception ex) {
                Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, MSBStrings.E0055, ex.Message);
                return(false);
            }

//			deviceType = plist.GetUIDeviceFamily ();

            if (plist.TryGetValue(ManifestKeys.MinimumOSVersion, out value))
            {
                if (!IPhoneSdkVersion.TryParse(value.Value, out minimumOSVersion))
                {
                    Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, MSBStrings.E0011, value);
                    return(false);
                }
            }
            else
            {
                switch (Platform)
                {
                case ApplePlatform.iOS:
                    IPhoneSdkVersion sdkVersion;
                    if (!IPhoneSdkVersion.TryParse(SdkVersion, out sdkVersion))
                    {
                        Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, MSBStrings.E0056, SdkVersion);
                        return(false);
                    }

                    minimumOSVersion = sdkVersion;
                    break;

                case ApplePlatform.WatchOS:
                case ApplePlatform.TVOS:
                    minimumOSVersion = IPhoneSdkVersion.UseDefault;
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Invalid framework: {0}", Platform));
                }
            }

            Directory.CreateDirectory(AppBundleDir);

            var executableLastWriteTime = default(DateTime);
            var executable = Path.Combine(AppBundleDir, ExecutableName);

            if (File.Exists(executable))
            {
                executableLastWriteTime = File.GetLastWriteTimeUtc(executable);
            }

            var result = base.Execute();

            CopiedFrameworks = GetCopiedFrameworks();

            if (File.Exists(executable) && File.GetLastWriteTimeUtc(executable) != executableLastWriteTime)
            {
                NativeExecutable = new TaskItem(executable);
            }

            return(result);
        }
        void EnsureiOSSdkPath()
        {
            var currentSDK = IPhoneSdks.GetSdk(Framework);
            IPhoneSdkVersion requestedSdkVersion;

            if (string.IsNullOrEmpty(SdkVersion))
            {
                requestedSdkVersion = IPhoneSdkVersion.UseDefault;
            }
            else if (!IPhoneSdkVersion.TryParse(SdkVersion, out requestedSdkVersion))
            {
                Log.LogError("Could not parse the SDK version '{0}'", SdkVersion);
                return;
            }

            var sdkVersion = requestedSdkVersion.ResolveIfDefault(currentSDK, SdkIsSimulator);

            if (!currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
            {
                sdkVersion = currentSDK.GetClosestInstalledSdk(sdkVersion, SdkIsSimulator);

                if (sdkVersion.IsUseDefault || !currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
                {
                    if (requestedSdkVersion.IsUseDefault)
                    {
                        Log.LogError("The Apple iOS SDK is not installed.");
                    }
                    else
                    {
                        Log.LogError("The iOS SDK version '{0}' is not installed, and no newer version was found.", requestedSdkVersion.ToString());
                    }
                    return;
                }
                Log.LogWarning("The iOS SDK version '{0}' is not installed. Using newer version '{1}' instead'.", requestedSdkVersion, sdkVersion);
            }

            SdkVersion = sdkVersion.ToString();

            var platformDir = currentSDK.GetPlatformPath(SdkIsSimulator);

            if (string.IsNullOrEmpty(platformDir) || !Directory.Exists(platformDir))
            {
                Log.LogError("Could not locate the iOS platform directory at path '{0}'", platformDir);
            }

            SdkRoot = currentSDK.GetSdkPath(sdkVersion, SdkIsSimulator);
            if (string.IsNullOrEmpty(SdkRoot) || !Directory.Exists(SdkRoot))
            {
                Log.LogError("Could not locate the iOS '{0}' SDK at path '{1}'", SdkVersion, SdkRoot);
            }

            // Note: Developer/Platforms/iPhoneOS.platform/Developer/usr is a physical directory, but
            // Developer/Platforms/iPhoneSimulator.platform/Developer/bin has always been a symlink
            // to Developer/bin and starting with Xcode 7 Beta 2, the usr symlink no longer exists.
            SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(platformDir, "Developer", "usr"));
            if (string.IsNullOrEmpty(SdkUsrPath))
            {
                SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(currentSDK.DeveloperRoot, "usr"));
                if (string.IsNullOrEmpty(SdkUsrPath))
                {
                    Log.LogError("Could not locate the iOS '{0}' SDK usr path at '{1}'", SdkVersion, SdkRoot);
                }
            }

            SdkBinPath = DirExists("SDK bin directory", Path.Combine(SdkUsrPath, "bin"));
            if (string.IsNullOrEmpty(SdkBinPath))
            {
                Log.LogError("Could not locate SDK bin directory");
            }

            SdkPlatform = SdkIsSimulator ? "iPhoneSimulator" : "iPhoneOS";
        }
        void EnsureWatchSdkPath()
        {
            var currentSDK = IPhoneSdks.GetSdk(Framework);
            IPhoneSdkVersion requestedSdkVersion;

            if (string.IsNullOrEmpty(SdkVersion))
            {
                requestedSdkVersion = IPhoneSdkVersion.UseDefault;
            }
            else if (!IPhoneSdkVersion.TryParse(SdkVersion, out requestedSdkVersion))
            {
                Log.LogError("Could not parse the SDK version '{0}'", SdkVersion);
                return;
            }

            var sdkVersion = requestedSdkVersion.ResolveIfDefault(currentSDK, SdkIsSimulator);

            if (!currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
            {
                sdkVersion = currentSDK.GetClosestInstalledSdk(sdkVersion, SdkIsSimulator);

                if (sdkVersion.IsUseDefault || !currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
                {
                    if (requestedSdkVersion.IsUseDefault)
                    {
                        Log.LogError("The Apple Watch SDK is not installed.");
                    }
                    else
                    {
                        Log.LogError("The Watch SDK version '{0}' is not installed, and no newer version was found.", requestedSdkVersion.ToString());
                    }
                    return;
                }
                Log.LogWarning("The Watch SDK version '{0}' is not installed. Using newer version '{1}' instead'.", requestedSdkVersion, sdkVersion);
            }

            SdkVersion = sdkVersion.ToString();

            var platformDir = currentSDK.GetPlatformPath(SdkIsSimulator);

            if (string.IsNullOrEmpty(platformDir) || !Directory.Exists(platformDir))
            {
                Log.LogError("Could not locate the WatchOS platform directory at path '{0}'", platformDir);
            }

            SdkRoot = currentSDK.GetSdkPath(sdkVersion, SdkIsSimulator);
            if (string.IsNullOrEmpty(SdkRoot) || !Directory.Exists(SdkRoot))
            {
                Log.LogError("Could not locate the WatchOS '{0}' SDK at path '{1}'", SdkVersion, SdkRoot);
            }

            SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(currentSDK.DeveloperRoot, "usr"));
            if (string.IsNullOrEmpty(SdkUsrPath))
            {
                Log.LogError("Could not locate the WatchOS '{0}' SDK usr path at '{1}'", SdkVersion, SdkRoot);
            }

            SdkBinPath = DirExists("SDK bin directory", Path.Combine(SdkUsrPath, "bin"));
            if (string.IsNullOrEmpty(SdkBinPath))
            {
                Log.LogError("Could not locate SDK bin directory");
            }

            SdkPlatform = SdkIsSimulator ? "WatchSimulator" : "WatchOS";
        }
Example #11
0
        void EnsureiOSSdkPath()
        {
            var currentSDK = IPhoneSdks.GetSdk(Framework);
            IPhoneSdkVersion requestedSdkVersion;

            if (string.IsNullOrEmpty(SdkVersion))
            {
                requestedSdkVersion = IPhoneSdkVersion.UseDefault;
            }
            else if (!IPhoneSdkVersion.TryParse(SdkVersion, out requestedSdkVersion))
            {
                Log.LogError(MSBStrings.E0025, SdkVersion);
                return;
            }

            var sdkVersion = requestedSdkVersion.ResolveIfDefault(currentSDK, SdkIsSimulator);

            if (!currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
            {
                sdkVersion = currentSDK.GetClosestInstalledSdk(sdkVersion, SdkIsSimulator);

                if (sdkVersion.IsUseDefault || !currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
                {
                    if (requestedSdkVersion.IsUseDefault)
                    {
                        Log.LogError(MSBStrings.E0038);
                    }
                    else
                    {
                        Log.LogError(MSBStrings.E0039, requestedSdkVersion.ToString());
                    }
                    return;
                }
                Log.LogWarning(MSBStrings.E0040, requestedSdkVersion, sdkVersion);
            }

            SdkVersion = sdkVersion.ToString();

            var platformDir = currentSDK.GetPlatformPath(SdkIsSimulator);

            if (string.IsNullOrEmpty(platformDir) || !Directory.Exists(platformDir))
            {
                Log.LogError(MSBStrings.E0041, platformDir);
            }

            SdkRoot = currentSDK.GetSdkPath(sdkVersion, SdkIsSimulator);
            if (string.IsNullOrEmpty(SdkRoot) || !Directory.Exists(SdkRoot))
            {
                Log.LogError(MSBStrings.E0042, SdkVersion, SdkRoot);
            }
            // Note: Developer/Platforms/iPhoneOS.platform/Developer/usr is a physical directory, but
            // Developer/Platforms/iPhoneSimulator.platform/Developer/bin has always been a symlink
            // to Developer/bin and starting with Xcode 7 Beta 2, the usr symlink no longer exists.
            // In Xcode 10 beta 1 Developer/Platforms/iPhoneOS.platform/Developer/usr reappeared,
            // but since it seems incomplete don't even check for it.
            if (AppleSdkSettings.XcodeVersion.Major < 10)
            {
                SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(platformDir, "Developer", "usr"));
            }

            if (string.IsNullOrEmpty(SdkUsrPath))
            {
                SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(currentSDK.DeveloperRoot, "usr"));
                if (string.IsNullOrEmpty(SdkUsrPath))
                {
                    Log.LogError(MSBStrings.E0043, SdkVersion, SdkRoot);
                }
            }

            SdkBinPath = DirExists("SDK bin directory", Path.Combine(SdkUsrPath, "bin"));
            if (string.IsNullOrEmpty(SdkBinPath))
            {
                Log.LogError(MSBStrings.E0032);
            }

            SdkPlatform = SdkIsSimulator ? "iPhoneSimulator" : "iPhoneOS";
        }
Example #12
0
        void EnsureWatchSdkPath()
        {
            var currentSDK = IPhoneSdks.GetSdk(Framework);
            IPhoneSdkVersion requestedSdkVersion;

            if (string.IsNullOrEmpty(SdkVersion))
            {
                requestedSdkVersion = IPhoneSdkVersion.UseDefault;
            }
            else if (!IPhoneSdkVersion.TryParse(SdkVersion, out requestedSdkVersion))
            {
                Log.LogError(MSBStrings.E0025, SdkVersion);
                return;
            }

            var sdkVersion = requestedSdkVersion.ResolveIfDefault(currentSDK, SdkIsSimulator);

            if (!currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
            {
                sdkVersion = currentSDK.GetClosestInstalledSdk(sdkVersion, SdkIsSimulator);

                if (sdkVersion.IsUseDefault || !currentSDK.SdkIsInstalled(sdkVersion, SdkIsSimulator))
                {
                    if (requestedSdkVersion.IsUseDefault)
                    {
                        Log.LogError(MSBStrings.E0026);
                    }
                    else
                    {
                        Log.LogError(MSBStrings.E0033, requestedSdkVersion.ToString());
                    }
                    return;
                }
                Log.LogWarning(MSBStrings.W0034, requestedSdkVersion, sdkVersion);
            }

            SdkVersion = sdkVersion.ToString();

            var platformDir = currentSDK.GetPlatformPath(SdkIsSimulator);

            if (string.IsNullOrEmpty(platformDir) || !Directory.Exists(platformDir))
            {
                Log.LogError(MSBStrings.E0035, platformDir);
            }

            SdkRoot = currentSDK.GetSdkPath(sdkVersion, SdkIsSimulator);
            if (string.IsNullOrEmpty(SdkRoot) || !Directory.Exists(SdkRoot))
            {
                Log.LogError(MSBStrings.E0036, SdkVersion, SdkRoot);
            }

            SdkUsrPath = DirExists("SDK Usr directory", Path.Combine(currentSDK.DeveloperRoot, "usr"));
            if (string.IsNullOrEmpty(SdkUsrPath))
            {
                Log.LogError(MSBStrings.E0037, SdkVersion, SdkRoot);
            }

            SdkBinPath = DirExists("SDK bin directory", Path.Combine(SdkUsrPath, "bin"));
            if (string.IsNullOrEmpty(SdkBinPath))
            {
                Log.LogError(MSBStrings.E0032);
            }

            SdkPlatform = SdkIsSimulator ? "WatchSimulator" : "WatchOS";
        }