Skip to content

Commit

Permalink
[Xamarin.MacDev] Add methods to map between iOS and macOS versions fo…
Browse files Browse the repository at this point in the history
…r Mac Catalyst. (#88)
  • Loading branch information
rolfbjarne authored Feb 11, 2021
1 parent 02d6d05 commit a3bb12c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Xamarin.MacDev/MacOSXSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,43 @@ string GetSdkPlistFilename (string version)
return Path.Combine (GetSdkPath (version), "SDKSettings.plist");
}

Dictionary<string, string> catalyst_version_map_ios_to_macos;
Dictionary<string, string> 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<string, string> ();
catalyst_version_map_macos_to_ios = new Dictionary<string, string> ();

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<string, string> GetCatalystVersionMap_iOS_to_Mac (string version)
{
LoadCatalystVersionMaps (version);
return catalyst_version_map_ios_to_macos;
}

public Dictionary<string, string> 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);
Expand Down

0 comments on commit a3bb12c

Please sign in to comment.