I have found a solution. Instead of placing the code in my main project, I placed it inside the iOS project itself in the ViewDidAppear function and put the global variable in my UIViewController class:
private IGattServer server = CrossBleAdapter.Current.CreateGattServer();
I think you need to access the adapter with the appropriate thread or at the appropriate time (after another initialization), therefore, why did it crash before. I could not find a suitable place to put this in my main project, so I'm not sure if I should put this code on every platform. Anyway, here is a solution for someone else with this problem.
source share