Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created July 22, 2016 18:41
Show Gist options
  • Save rolfbjarne/838c51d444cf4a7293e48999a0330adf to your computer and use it in GitHub Desktop.
Save rolfbjarne/838c51d444cf4a7293e48999a0330adf to your computer and use it in GitHub Desktop.
commit 8044be58363e7e97641a5debdd1946ed1bcdb9b7
Author: Rolf Bjarne Kvinge <[email protected]>
Date: Fri Jul 22 20:41:22 2016 +0200
Enable ExternalAccessory for tvOS and teach the static registrar about the lack of simulator headers.
diff --git a/src/frameworks.sources b/src/frameworks.sources
index 3f2c3f4..d82a436 100644
--- a/src/frameworks.sources
+++ b/src/frameworks.sources
@@ -1669,6 +1669,7 @@ TVOS_FRAMEWORKS = \
CoreSpotlight \
CoreText \
CoreVideo \
+ ExternalAccessory \
GLKit \
GameController \
GameKit \
diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs
index 952e05f..d42deb1 100644
--- a/tools/common/Frameworks.cs
+++ b/tools/common/Frameworks.cs
@@ -318,7 +318,7 @@ public class Frameworks : Dictionary <string, Framework>
{ "MapKit", "MapKit", 9, 2 },
- //{ "ExternalAccessory", "ExternalAccessory", 10 },
+ { "ExternalAccessory", "ExternalAccessory", 10 },
{ "MultipeerConnectivity", 10 },
{ "ReplayKit", "ReplayKit", 10 },
{ "UserNotifications", "UserNotifications", 10 },
diff --git a/tools/common/StaticRegistrar.cs b/tools/common/StaticRegistrar.cs
index 7ce2466..e12ceae 100644
--- a/tools/common/StaticRegistrar.cs
+++ b/tools/common/StaticRegistrar.cs
@@ -1782,6 +1782,12 @@ namespace XamCore.Registrar {
header.WriteLine ("#import <WatchKit/WatchKit.h>");
namespaces.Add ("UIKit");
return;
+ case "ExternalAccessory":
+#if !MONOMAC
+ if (IsSimulator && Driver.App.Platform == Xamarin.Utils.ApplePlatform.TVOS)
+ return; // No headers provided for AppleTV/simulator.
+#endif
+ goto default;
default:
h = string.Format ("<{0}/{0}.h>", ns);
break;
@@ -2142,6 +2148,24 @@ namespace XamCore.Registrar {
return sb != null ? sb.ToString () : value;
}
+ static bool IsExternalAccessoryType (ObjCType type)
+ {
+ var ns = type.Type.Namespace;
+
+ var t = type.Type;
+ while (string.IsNullOrEmpty (ns) && t.DeclaringType != null) {
+ t = t.DeclaringType;
+ ns = t.Namespace;
+ }
+
+ switch (ns) {
+ case "ExternalAccessory":
+ return true;
+ default:
+ return false;
+ }
+ }
+
static bool IsMetalType (ObjCType type)
{
var ns = type.Type.Namespace;
@@ -2186,6 +2210,9 @@ namespace XamCore.Registrar {
if (isPlatformType && IsSimulatorOrDesktop && IsMetalType (@class))
continue; // Metal isn't supported in the simulator.
+
+ if (IsSimulatorOrDesktop && Driver.App.Platform == Xamarin.Utils.ApplePlatform.TVOS && IsExternalAccessoryType (@class))
+ continue; // ExternalAccessory's headers aren't available for tvOS/Simulator.
#endif
if (@class.IsFakeProtocol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment