From a3bb12c542c1d6e5feef33f3a138b7270eef394a Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 11 Feb 2021 16:30:38 +0100 Subject: [PATCH] [Xamarin.MacDev] Add methods to map between iOS and macOS versions for Mac Catalyst. (#88) --- Xamarin.MacDev/MacOSXSdk.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Xamarin.MacDev/MacOSXSdk.cs b/Xamarin.MacDev/MacOSXSdk.cs index fed82f3..4f04044 100644 --- a/Xamarin.MacDev/MacOSXSdk.cs +++ b/Xamarin.MacDev/MacOSXSdk.cs @@ -159,6 +159,43 @@ string GetSdkPlistFilename (string version) return Path.Combine (GetSdkPath (version), "SDKSettings.plist"); } + Dictionary catalyst_version_map_ios_to_macos; + Dictionary catalyst_version_map_macos_to_ios; + + void LoadCatalystVersionMaps (string version) + { + if (catalyst_version_map_ios_to_macos != null && catalyst_version_map_macos_to_ios != null) + return; + + catalyst_version_map_ios_to_macos = new Dictionary (); + catalyst_version_map_macos_to_ios = new Dictionary (); + + var fn = GetSdkPlistFilename (version); + var plist = PDictionary.FromFile (fn); + if (plist.TryGetValue ("VersionMap", out PDictionary versionMap)) { + if (versionMap.TryGetValue ("iOSMac_macOS", out PDictionary versionMapiOSToMac)) { + foreach (var kvp in versionMapiOSToMac) + catalyst_version_map_ios_to_macos [kvp.Key] = ((PString) kvp.Value).Value; + } + if (versionMap.TryGetValue ("macOS_iOSMac", out PDictionary versionMapMacToiOS)) { + foreach (var kvp in versionMapMacToiOS) + catalyst_version_map_macos_to_ios [kvp.Key] = ((PString) kvp.Value).Value; + } + } + } + + public Dictionary GetCatalystVersionMap_iOS_to_Mac (string version) + { + LoadCatalystVersionMaps (version); + return catalyst_version_map_ios_to_macos; + } + + public Dictionary GetCatalystVersionMap_Mac_to_iOS (string version) + { + LoadCatalystVersionMaps (version); + return catalyst_version_map_macos_to_ios; + } + bool IAppleSdk.SdkIsInstalled (IAppleSdkVersion version, bool isSimulator) { return SdkIsInstalled ((AppleSdkVersion) version);