|
2 | 2 | using System;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.Reflection;
|
| 5 | +using System.Runtime.InteropServices; |
5 | 6 | using Foundation;
|
6 | 7 | using UIKit;
|
7 | 8 | using MonoTouch.NUnit.UI;
|
@@ -66,12 +67,33 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
|
66 | 67 |
|
67 | 68 | static void Main (string[] args)
|
68 | 69 | {
|
| 70 | +#if __MACCATALYST__ |
| 71 | + NativeLibrary.SetDllImportResolver (typeof (NSObject).Assembly, DllImportResolver); |
| 72 | + NativeLibrary.SetDllImportResolver (typeof (AppDelegate).Assembly, DllImportResolver); |
| 73 | +#endif |
69 | 74 | // Make sure we have at least one reference to the bindings project so that mcs doesn't strip the reference to it.
|
70 | 75 | GC.KeepAlive (typeof(Bindings.Test.UltimateMachine));
|
71 | 76 |
|
72 | 77 | UIApplication.Main (args, null, typeof (AppDelegate));
|
73 | 78 | }
|
74 | 79 |
|
| 80 | +#if __MACCATALYST__ |
| 81 | + // This is a workaround for a temporary issue in the .NET runtime |
| 82 | + // See https://github.com/xamarin/maccore/issues/2668 |
| 83 | + // The issue is present in .NET 7.0.5, and will likely be fixed in .NET 7.0.6. |
| 84 | + static IntPtr DllImportResolver (string libraryName, global::System.Reflection.Assembly assembly, DllImportSearchPath? searchPath) |
| 85 | + { |
| 86 | + switch (libraryName) { |
| 87 | + case "/System/Library/Frameworks/SceneKit.framework/SceneKit": |
| 88 | + case "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit": |
| 89 | + var rv = NativeLibrary.Load (libraryName); |
| 90 | + Console.WriteLine ($"DllImportResolver callback loaded library \"{libraryName}\" from a P/Invoke in \"{assembly}\" => 0x{rv.ToString ("x")}"); |
| 91 | + return rv; |
| 92 | + default: |
| 93 | + return IntPtr.Zero; |
| 94 | + } |
| 95 | + } |
| 96 | +#endif |
75 | 97 | public static void PresentModalViewController (UIViewController vc, double duration)
|
76 | 98 | {
|
77 | 99 | var bckp = window.RootViewController;
|
|
0 commit comments