diff --git a/src/Constants.iOS.cs.in b/src/Constants.iOS.cs.in index e42f0f725819..b88720ff3c07 100644 --- a/src/Constants.iOS.cs.in +++ b/src/Constants.iOS.cs.in @@ -146,6 +146,7 @@ namespace ObjCRuntime { public const string AutomaticAssessmentConfigurationLibrary = "/System/Library/Frameworks/AutomaticAssessmentConfiguration.framework/AutomaticAssessmentConfiguration"; // iOS 14.0 public const string AppClipLibrary = "/System/Library/Frameworks/AppClip.framework/AppClip"; + public const string MediaSetupLibrary = "/System/Library/Frameworks/MediaSetup.framework/MediaSetup"; public const string UniformTypeIdentifiersLibrary = "/System/Library/Frameworks/UniformTypeIdentifiers.framework/UniformTypeIdentifiers"; } } diff --git a/src/frameworks.sources b/src/frameworks.sources index 39aec6c3f82e..d32839753436 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1943,6 +1943,7 @@ IOS_FRAMEWORKS = \ MapKit \ MediaAccessibility \ MediaPlayer \ + MediaSetup \ MediaToolbox \ Messages \ MessageUI \ diff --git a/src/mediasetup.cs b/src/mediasetup.cs new file mode 100644 index 000000000000..9aead8ec0db4 --- /dev/null +++ b/src/mediasetup.cs @@ -0,0 +1,70 @@ +using System; +using Foundation; +using ObjCRuntime; +using UIKit; + +namespace MediaSetup { + + [NoTV][NoWatch][NoMac] + [iOS (14,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface MSServiceAccount { + + [Export ("initWithServiceName:accountName:")] + [DesignatedInitializer] + IntPtr Constructor (string serviceName, string accountName); + + [Export ("serviceName")] + string ServiceName { get; } + + [Export ("accountName")] + string AccountName { get; } + + [NullAllowed, Export ("clientID")] + string ClientId { get; set; } + + [NullAllowed, Export ("clientSecret")] + string ClientSecret { get; set; } + + [NullAllowed, Export ("configurationURL", ArgumentSemantic.Copy)] + NSUrl ConfigurationUrl { get; set; } + + [NullAllowed, Export ("authorizationTokenURL", ArgumentSemantic.Copy)] + NSUrl AuthorizationTokenUrl { get; set; } + + [NullAllowed, Export ("authorizationScope")] + string AuthorizationScope { get; set; } + } + + interface IMSAuthenticationPresentationContext {} + + [NoTV][NoWatch][NoMac] + [iOS (14,0)] + [Protocol] + interface MSAuthenticationPresentationContext { + + [Abstract] + [NullAllowed, Export ("presentationAnchor")] + UIWindow PresentationAnchor { get; } + } + + [NoTV][NoWatch][NoMac] + [iOS (14,0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface MSSetupSession { + + [Export ("initWithServiceAccount:")] + IntPtr Constructor (MSServiceAccount serviceAccount); + + [Export ("startWithError:")] + bool Start ([NullAllowed] out NSError error); + + [NullAllowed, Export ("presentationContext", ArgumentSemantic.Weak)] + IMSAuthenticationPresentationContext PresentationContext { get; set; } + + [Export ("account", ArgumentSemantic.Strong)] + MSServiceAccount Account { get; } + } +} diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index 10511b41d376..174718173d98 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -982,6 +982,13 @@ public void ConstantsCheck () Assert.True (CheckLibrary (s), fi.Name); break; #endif +#if __IOS__ + case "MediaSetupLibrary": + // Xcode 12 beta 2 does not ship this framework/headers for the simulator + if (Runtime.Arch == Arch.DEVICE) + Assert.True (CheckLibrary (s), fi.Name); + break; +#endif #if __TVOS__ case "MetalPerformanceShadersLibrary": // not supported in tvOS (12.1) simulator so load fails diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index 58ed25735cb6..59c02d0d1948 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -386,6 +386,9 @@ protected override bool Skip (Type type, string protocolName) case "TVTopShelfSectionedItem": return true; #endif + // Xcode 12 beta 2 + case "MSServiceAccount": + return true; } break; case "NSSecureCoding": @@ -614,6 +617,9 @@ protected override bool Skip (Type type, string protocolName) case "TVTopShelfSectionedItem": return true; #endif + // Xcode 12 beta 2 + case "MSServiceAccount": + return true; } break; case "NSCopying": diff --git a/tests/xtro-sharpie/iOS-MediaSetup.ignore b/tests/xtro-sharpie/iOS-MediaSetup.ignore new file mode 100644 index 000000000000..8936278ff27d --- /dev/null +++ b/tests/xtro-sharpie/iOS-MediaSetup.ignore @@ -0,0 +1,2 @@ +!missing-field! MediaSetupVersionNumber not bound +!missing-field! MediaSetupVersionString not bound diff --git a/tests/xtro-sharpie/iOS-MediaSetup.todo b/tests/xtro-sharpie/iOS-MediaSetup.todo deleted file mode 100644 index 003dab09f9f9..000000000000 --- a/tests/xtro-sharpie/iOS-MediaSetup.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-field! MediaSetupVersionNumber not bound -!missing-field! MediaSetupVersionString not bound -!missing-protocol! MSAuthenticationPresentationContext not bound -!missing-selector! MSServiceAccount::accountName not bound -!missing-selector! MSServiceAccount::authorizationScope not bound -!missing-selector! MSServiceAccount::authorizationTokenURL not bound -!missing-selector! MSServiceAccount::clientID not bound -!missing-selector! MSServiceAccount::clientSecret not bound -!missing-selector! MSServiceAccount::configurationURL not bound -!missing-selector! MSServiceAccount::initWithServiceName:accountName: not bound -!missing-selector! MSServiceAccount::serviceName not bound -!missing-selector! MSServiceAccount::setAuthorizationScope: not bound -!missing-selector! MSServiceAccount::setAuthorizationTokenURL: not bound -!missing-selector! MSServiceAccount::setClientID: not bound -!missing-selector! MSServiceAccount::setClientSecret: not bound -!missing-selector! MSServiceAccount::setConfigurationURL: not bound -!missing-selector! MSSetupSession::account not bound -!missing-selector! MSSetupSession::initWithServiceAccount: not bound -!missing-selector! MSSetupSession::presentationContext not bound -!missing-selector! MSSetupSession::setPresentationContext: not bound -!missing-selector! MSSetupSession::startWithError: not bound -!missing-type! MSServiceAccount not bound -!missing-type! MSSetupSession not bound diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index 7d96953add61..268aa49b3805 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -336,6 +336,7 @@ public static Frameworks GetiOSFrameworks (Application app) { "AutomaticAssessmentConfiguration", "AutomaticAssessmentConfiguration", 13, 4 }, { "AppClip", "AppClip", 14,0 }, + { "MediaSetup", "MediaSetup", new Version (14, 0), NotAvailableInSimulator /* no headers in beta 2 */ }, { "UniformTypeIdentifiers", "UniformTypeIdentifiers", 14,0 }, // the above MUST be kept in sync with simlauncher @@ -529,17 +530,26 @@ public static void Gather (Application app, AssemblyDefinition product_assembly, // This checks if a framework is unavailable due to bugs in Xcode (such as Apple forgetting to ship a library or headers for a framework, which seems to happen at least once a year). public static bool IsFrameworkBroken (Application app, string framework) { - if (app.Platform == ApplePlatform.WatchOS && app.IsSimulatorBuild && Driver.XcodeProductVersion == "12A6163b" /* Xcode 12 beta 12 */) { + if (app.IsSimulatorBuild && Driver.XcodeProductVersion == "12A6163b" /* Xcode 12 beta 12 */) { switch (framework) { + // Apple seems to have forgotten to ship the several libraries for the simulator in Xcode 12 betas (it's still available for device builds). + // https://github.com/xamarin/maccore/issues/2244 case "CoreML": case "CoreVideo": - // Apple seems to have forgotten to ship the several libraries for the simulator in Xcode 12 betas (it's still available for device builds). - // https://github.com/xamarin/maccore/issues/2244 - Driver.Log (1, $"Can't use '{framework}' in the simulator because Apple didn't ship it with Xcode 12 beta {Driver.XcodeProductVersion}"); - return true; + if (app.Platform != ApplePlatform.WatchOS) + return false; + break; + // https://github.com/xamarin/maccore/issues/2266 + case "MediaSetup": + if (app.Platform != ApplePlatform.iOS) + return false; + break; + default: + return false; } + Driver.Log (1, $"Can't use '{framework}' in the simulator because Apple didn't ship it with Xcode 12 beta {Driver.XcodeProductVersion}"); + return true; } - return false; } #endif