Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/monotouch-test/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using Foundation;
using UIKit;
using MonoTouch.NUnit.UI;
Expand Down Expand Up @@ -66,12 +67,33 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)

static void Main (string[] args)
{
#if __MACCATALYST__
NativeLibrary.SetDllImportResolver (typeof (NSObject).Assembly, DllImportResolver);
NativeLibrary.SetDllImportResolver (typeof (AppDelegate).Assembly, DllImportResolver);
#endif
// Make sure we have at least one reference to the bindings project so that mcs doesn't strip the reference to it.
GC.KeepAlive (typeof(Bindings.Test.UltimateMachine));

UIApplication.Main (args, null, typeof (AppDelegate));
}

#if __MACCATALYST__
// This is a workaround for a temporary issue in the .NET runtime
// See https://github.com/xamarin/maccore/issues/2668
// The issue is present in .NET 7.0.5, and will likely be fixed in .NET 7.0.6.
static IntPtr DllImportResolver (string libraryName, global::System.Reflection.Assembly assembly, DllImportSearchPath? searchPath)
{
switch (libraryName) {
case "/System/Library/Frameworks/SceneKit.framework/SceneKit":
case "/System/Library/Frameworks/SceneKit.framework/Versions/A/SceneKit":
var rv = NativeLibrary.Load (libraryName);
Console.WriteLine ($"DllImportResolver callback loaded library \"{libraryName}\" from a P/Invoke in \"{assembly}\" => 0x{rv.ToString ("x")}");
return rv;
default:
return IntPtr.Zero;
}
}
#endif
public static void PresentModalViewController (UIViewController vc, double duration)
{
var bckp = window.RootViewController;
Expand Down