Error initializing Realm on IOS only (maui.net)

I cannot get a Maui.net app to initialize the realm for IOS. it works fine on windows and android, but not IOS.
for troubleshooting purposes, I installed the .net “todo” example referenced in the Setup tutorial.
It is hanging up at the same location and giving the same error.
I’m using Realm 11.5 (li even tried older versions)
target platform is net7.0 for all platforms.
I’ve tried deleting the bins, cleaning, rebuilding, etc…

during debugging it seems the problem is

Snippet

app = Realms.Sync.App.Create(appConfiguration);

this line of code throws an exception(only on IOS)

“The type initializer for ‘Realms.Sync.AppHandle’ threw an exception.”

my output window shows the following


[0:] An error occurred: ‘realm-wrappers’. Callstack: ’ at Realms.SynchronizationContextScheduler.Initialize()
at Realms.NativeCommon.Initialize()
at Realms.Sync.AppHandle…cctor()’
2023-10-02 14:17:04.275 Xamarin.PreBuilt.iOS[1766:1382615] Warning: observer object was not disposed manually with Dispose()…

The is from the unmodified “todo” app (except the config file reflects app id)
it works perfect for windows and android.

We’ll need some info about your build environment to be able to try and replicate this:

  • What platform are you developing on? (i.e. Windows with macOS host or natively on macOS)
  • What is the version of your development environment (e.g. Visual Studio or MSBuild if you’re building from the command line)
  • What is the version of Xcode
  • What is the version of iOS you’re deploying on
  • Are you deploying on a physical device or the simulator

I’m developing on windows (visual studios 2022 ver 17.6.5)
the mac connected is using Ventura 13.5.2
Xcode is ver 15.0
IOS ver is 16.7 on Iphone Xr (i also tried on older phone with ver 15.7.9)
I am using real device.
The app runs and deploys if I remark out the code

app = Realms.Sync.App.Create(appConfiguration);

Are you deploying a hot-restart enabled app? If so, this is not supported and tracked by Wrappers not found in hot restart-enabled build for MAUI · Issue #3137 · realm/realm-dotnet · GitHub. Unfortunately, there’s no workaround at the moment as it seems to be a limitation of the way Microsoft packages native assemblies inside the container app.