protected string ResolveXCFramework(string xcframework)
        {
            var platformName = PlatformFrameworkHelper.GetOperatingSystem(TargetFrameworkMoniker);

            // PlatformFrameworkHelper.GetOperatingSystem returns "osx" which does not work for xcframework
            if (platformName == "osx")
            {
                platformName = "macos";
            }

            var variant = SdkIsSimulator ? "simulator" : null;

            try {
                var plist = PDictionary.FromFile(Path.Combine(xcframework, "Info.plist"));
                var dir   = ResolveXCFramework(plist, platformName, variant, Architectures);
                if (!String.IsNullOrEmpty(dir))
                {
                    return(Path.Combine(xcframework, dir));
                }

                // either the format was incorrect or we could not find a matching framework
                // note: last part is not translated since it match the (non-translated) keys inside the `Info.plist`
                var msg = (dir == null) ? MSBStrings.E0174 : MSBStrings.E0175 + $" SupportedPlatform: '{platformName}', SupportedPlatformVariant: '{variant}', SupportedArchitectures: '{Architectures}'.";
                Log.LogError(msg, xcframework);
            }
            catch (Exception) {
                Log.LogError(MSBStrings.E0174, xcframework);
            }
            return(null);
        }
Esempio n. 2
0
        protected string?ResolveXCFramework(string xcframework)
        {
            string platformName;

            switch (Platform)
            {
            case Utils.ApplePlatform.MacCatalyst:
                platformName = "ios";
                break;

            case Utils.ApplePlatform.MacOSX:
                // PlatformFrameworkHelper.GetOperatingSystem returns "osx" which does not work for xcframework
                platformName = "macos";
                break;

            default:
                platformName = PlatformFrameworkHelper.GetOperatingSystem(TargetFrameworkMoniker);
                break;
            }

            string?variant = null;

            if (Platform == Utils.ApplePlatform.MacCatalyst)
            {
                variant = "maccatalyst";
            }
            else if (SdkIsSimulator)
            {
                variant = "simulator";
            }

            try {
                var plist = PDictionary.FromFile(Path.Combine(xcframework, "Info.plist"));
                var path  = ResolveXCFramework(plist, platformName, variant, Architectures !);
                if (!String.IsNullOrEmpty(path))
                {
                    return(Path.Combine(xcframework, path));
                }

                // either the format was incorrect or we could not find a matching framework
                // note: last part is not translated since it match the (non-translated) keys inside the `Info.plist`
                var msg = (path == null) ? MSBStrings.E0174 : MSBStrings.E0175 + $" SupportedPlatform: '{platformName}', SupportedPlatformVariant: '{variant}', SupportedArchitectures: '{Architectures}'.";
                Log.LogError(msg, xcframework);
            }
            catch (Exception) {
                Log.LogError(MSBStrings.E0174, xcframework);
            }
            return(null);
        }