Error on Xamarin forms when running on iOS only?


#1

I downloaded the QuickJournal sample app. Set up my account and added a user in Realm Cloud.
After that, I added this simple code to login the user.

Uri authURL = new Uri("$$InstanceUrlHere$$");
Credentials credentials = Credentials.UsernamePassword("Ali", "123", createUser: false);
try
{
    //trying to login using realm default authticaion: username and password
    var user = await User.LoginAsync(credentials, authURL);
    await Application.Current.MainPage.DisplayAlert("Confirmation", "User Identitiy from Realm Login: " + user.Identity, "Ok");
}
catch(Exception ex)
{
    await Application.Current.MainPage.DisplayAlert("Error", "Error while Trying to login", "Ok");
    System.Diagnostics.Debug.WriteLine("Error while Trying to login: " + ex);
}

Code is working fine on Android Emulator. But, on iOS, I am getting the following error on the LoginAsync step:

System.TypeInitializationException: The type initializer for 'Realms.Sync.SharedRealmHandleExtensions' threw an exception. ---> System.EntryPointNotFoundException: realm_install_syncsession_callbacks
  at (wrapper managed-to-native) Realms.Sync.SharedRealmHandleExtensions+NativeMethods.install_syncsession_callbacks(Realms.Sync.SharedRealmHandleExtensions/NativeMethods/RefreshAccessTokenCallbackDelegate,Realms.Sync.SharedRealmHandleExtensions/NativeMethods/SessionErrorCallback,Realms.Sync.SharedRealmHandleExtensions/NativeMethods/SessionProgressCallback,Realms.Sync.SharedRealmHandleExtensions/NativeMethods/SessionWaitCallback)
  at Realms.Sync.SharedRealmHandleExtensions..cctor () [0x0004e] in <ea4ca0c9fb2d4604a0791d766f11362f>:0

#2

It’s partially working fine now after Xamarin forms,Realm, Fody, and other libraries.
The login is fine but the app is crashing if I debug and step into the code one step at a time. While when I run it, it’s working fine which doesn’t make any sense.

2018-05-28 11:15:48.815 QuickJournal.iOS[6014:82756] error: * Assertion at /Users/builder/data/lanes/5944/408d3574/source/xamarin-macios/external/mono/mono/mini/debugger-agent.c:4831, condition `array->len == 1' not met
2018-05-28 11:15:48.815 QuickJournal.iOS[6014:82756] critical: Stacktrace:
2018-05-28 11:15:48.815 QuickJournal.iOS[6014:82756] critical:   at <unknown> <0xffffffff>
2018-05-28 11:15:48.815 QuickJournal.iOS[6014:82756] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) [0x0005c] in <3e8f15839fa642a983cc9714989b03cd>:0
2018-05-28 11:15:48.815 QuickJournal.iOS[6014:82756] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.10.1.178/src/Xamarin.iOS/UIKit/UIApplication.cs:79
2018-05-28 11:15:48.816 QuickJournal.iOS[6014:82756] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.10.1.178/src/Xamarin.iOS/UIKit/UIApplication.cs:63
2018-05-28 11:15:48.816 QuickJournal.iOS[6014:82756] critical:   at QuickJournal.iOS.Application.Main (string[]) [0x00001] in /Users/sabicmobility/Downloads/examples/QuickJournal/iOS/Main.cs:17
2018-05-28 11:15:48.816 QuickJournal.iOS[6014:82756] critical:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <09dd1135accb49cf94114ae0184e3116>:0
2018-05-28 11:15:48.816 QuickJournal.iOS[6014:82756] critical: 
Native stacktrace:

2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	0   QuickJournal.iOS                    0x000000010aa28b54 mono_handle_native_crash + 244
2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	1   libsystem_platform.dylib            0x000000011205ff5a _sigtramp + 26
2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	2   ???                                 0x000000000000ffff 0x0 + 65535
2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	3   libsystem_c.dylib                   0x0000000111c9ac97 abort + 127
2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	4   QuickJournal.iOS                    0x000000010ac2ecc0 _ZL12log_callbackPKcS0_S0_iPv + 64
2018-05-28 11:15:48.828 QuickJournal.iOS[6014:82756] critical: 	5   QuickJournal.iOS                    0x000000010abfdba3 monoeg_g_logv + 83
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	6   QuickJournal.iOS                    0x000000010abfde4f monoeg_assertion_message + 143
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	7   QuickJournal.iOS                    0x000000010a9738de get_this_async_id + 382
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	8   QuickJournal.iOS                    0x000000010a972a93 ss_start + 723
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	9   QuickJournal.iOS                    0x000000010a9664fa process_breakpoint + 1530
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	10  QuickJournal.iOS                    0x000000010a965e8e debugger_agent_breakpoint_from_context + 158
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	11  ???                                 0x000000012e8d807f 0x0 + 5075992703
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	12  ???                                 0x0000000131e4792b 0x0 + 5132024107
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	13  ???                                 0x0000000131e34a7c 0x0 + 5131946620
2018-05-28 11:15:48.829 QuickJournal.iOS[6014:82756] critical: 	14  ???                                 0x0000000131e33e93 0x0 + 5131943571
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	15  ???                                 0x0000000131e33ad4 0x0 + 5131942612
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	16  ???                                 0x0000000131e3337b 0x0 + 5131940731
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	17  ???                                 0x0000000131e31c63 0x0 + 5131934819
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	18  ???                                 0x0000000131e34a7c 0x0 + 5131946620
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	19  ???                                 0x0000000131e33e93 0x0 + 5131943571
2018-05-28 11:15:48.830 QuickJournal.iOS[6014:82756] critical: 	20  ???                                 0x000000013219d369 0x0 + 5135520617
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	21  ???                                 0x000000012fdcc816 0x0 + 5097965590
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	22  QuickJournal.iOS                    0x000000010aa3b053 mono_jit_runtime_invoke + 1443
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	23  QuickJournal.iOS                    0x000000010ab1a18f mono_runtime_invoke_checked + 127
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	24  QuickJournal.iOS                    0x000000010ab1da8c mono_runtime_invoke + 76
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	25  QuickJournal.iOS                    0x000000010ac37bb2 xamarin_invoke_trampoline + 6018
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	26  QuickJournal.iOS                    0x000000010ac3fa5d xamarin_arch_trampoline + 189
2018-05-28 11:15:48.831 QuickJournal.iOS[6014:82756] critical: 	27  QuickJournal.iOS                    0x000000010ac40e91 xamarin_x86_64_common_trampoline + 110
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	28  Foundation                          0x000000010eaf0d5e __NSThreadPerformPerform + 330
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	29  CoreFoundation                      0x000000010f8bdbb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	30  CoreFoundation                      0x000000010f8a24af __CFRunLoopDoSources0 + 271
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	31  CoreFoundation                      0x000000010f8a1a6f __CFRunLoopRun + 1263
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	32  CoreFoundation                      0x000000010f8a130b CFRunLoopRunSpecific + 635
2018-05-28 11:15:48.832 QuickJournal.iOS[6014:82756] critical: 	33  GraphicsServices                    0x0000000116794a73 GSEventRunModal + 62
2018-05-28 11:15:48.833 QuickJournal.iOS[6014:82756] critical: 	34  UIKit                               0x000000010c8f50b7 UIApplicationMain + 159
2018-05-28 11:15:48.833 QuickJournal.iOS[6014:82756] critical: 	35  ???                                 0x00000001300eed77 0x0 + 5101251959
2018-05-28 11:15:48.833 QuickJournal.iOS[6014:82756] critical: 	36  ???                                 0x00000001300eead3 0x0 + 5101251283
2018-05-28 11:15:48.833 QuickJournal.iOS[6014:82756] critical: 
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================