question

GordonS-9701 avatar image
0 Votes"
GordonS-9701 asked JarvanZhang-MSFT commented

Xamarin Forms app fails to run / debug on physical iPhone

I have a Xamarin Forms solution, Visual Studio 2019, on Windows 10. I have a Mac at MacInCloud for compiling purposes.

I have managed to get the iOS app to run in the simulator on the Mac (mostly, got some weird issues!)

The Android project runs fine on the simulator and has been tested on multiple physical Android devices.

When I select Debug & iPhone, I get my iPhone listed. I click it to Debug and the app is built and installed on my iPhone. Visual Studio then asks me to launch the app. I do that and the standard blue splash screen appears and Visual Studio appears to start debug mode. 5 seconds or so later, the app on my iPhone closes (actually, goes to the background) and debugging stops.

I tried setting a number of breakpoints to try and see if it's starting at all and it does not appear to be.


I get this in the Debug window, it appears to be unable to find 3 assemblies:

 > 2021-05-21 10:05:48.771 Xamarin.PreBuilt.iOS[2609:1266239] Xamarin.iOS: Processing: 'start profiler: no'
 2021-05-21 10:05:48.771 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Profiler not loaded (disabled)
    
 2021-05-21 10:05:48.766 Xamarin.PreBuilt.iOS[2609:1266239] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 6
    
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.iOS.dll [External]
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/System.dll [External]
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Mono.Security.dll [External]
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS.exe [External]
 Thread started:  #2
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS.Library.dll [External]
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/netstandard.dll [External]
 Loaded assembly: /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/System.Core.dll [External]
 2021-05-21 10:05:49.395 Xamarin.PreBuilt.iOS[2609:1266192] Content folder: /var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content
    
 Thread started:  #3
 2021-05-21 10:05:49.533 Xamarin.PreBuilt.iOS[2609:1266192] Forms app path /var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content/MyApp.iOS.exe
    
 2021-05-21 10:05:49.534 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Platform.iOS' (culture: '')
 2021-05-21 10:05:49.534 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Platform.iOS' (culture: '')
    
 2021-05-21 10:05:49.535 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'Firebase.CloudMessaging' (culture: '')
    
 2021-05-21 10:05:49.535 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'Firebase.CloudMessaging' (culture: '')
    
 2021-05-21 10:05:49.536 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'MyApp' (culture: '')
    
 2021-05-21 10:05:49.536 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.iOS: Unable to locate assembly 'MyApp' (culture: '')
    
 Loaded assembly: /private/var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content/MyApp.iOS.exe
 Loaded assembly: /private/var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content/Xamarin.Forms.Platform.iOS.dll [External]
 Loaded assembly: /private/var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content/Firebase.CloudMessaging.dll [External]
 Loaded assembly: /private/var/mobile/Containers/Data/Application/BCE69DDC-970B-4869-8B20-A98A7F61A6AA/Documents/MyApp.iOS.content/MyApp.dll
 2021-05-21 10:05:49.567 Xamarin.PreBuilt.iOS[2609:1266192] Xamarin.Forms AppDelegate name: AppDelegate
    
    
 =================================================================
  Native Crash Reporting
 =================================================================
 Got a segv while executing native code. This usually indicates
 a fatal error in the mono runtime or one of the native libraries 
 used by your application.
 =================================================================
    
 =================================================================
  Native stacktrace:
 =================================================================
    
  0x100ed4120 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info
  0x100ecacbc - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash
    
  0x101080970 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : do_icall
  0x10107f010 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : do_icall_wrapper
    
  0x101075a8c - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : interp_exec_method_full
    
  0x100ed7a60 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_sigsegv_signal_handler_debug
  0x1e85b429c - /usr/lib/system/libsystem_platform.dylib : <redacted>
  0x1b14ea660 - /usr/lib/libobjc.A.dylib : <redacted>
  0x19c6c33b4 - /usr/lib/system/libdyld.dylib : <redacted>
  0x19c6b3948 - /usr/lib/system/libdyld.dylib : <redacted>
  0x19c6c3f30 - /usr/lib/system/libdyld.dylib : <redacted>
  0x19c6c39c0 - /usr/lib/system/libdyld.dylib : <redacted>
  0x19c6c5928 - /usr/lib/system/libdyld.dylib : <redacted>
  0x19c6b6ecc - /usr/lib/system/libdyld.dylib : <redacted>
    
  0x100e87c34 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : main
  0x19c6b1cf8 - /usr/lib/system/libdyld.dylib : <redacted>
    
 =================================================================
  Basic Fault Address Reporting
 =================================================================
 Memory around native instruction pointer (0x104fcfe88):0x104fcfe78  f6 57 c3 a8 c0 03 5f d6 00 08 40 f9 c0 03 5f d6  .W...._...@..._.
 0x104fcfe88  f4 4f be a9 
 fd 7b 01 a9 fd 43 00 91 1f 20 03 d5  .O...{...C... ..
 0x104fcfe98  08 0d 02 58 00 01 40 fd 1f 20 03 d5 21 fb 00 5c  ...X..@.. ..!..\
 0x104fcfea8  00 20 61 1e 65 02 00 54 e0 e7 01 30 
  0x101073eb0 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : interp_runtime_invoke
  0x100edad3c - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_jit_runtime_invoke
  0x100f892c0 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_runtime_invoke_checked
  0x100f8e564 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_runtime_exec_main_checked
  0x100ebf8f4 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_jit_exec
  0x101071984 - /private/var/containers/Bundle/Application/48D235AC-960C-4C55-8478-76D9ACBEC38D/MyApp.iOS.app/Xamarin.PreBuilt.iOS : xamarin_main
    
 1f 20 03 d5  . a.e..T...0. ..
    
 =================================================================
  Managed Stacktrace:
 =================================================================
    at <unknown> <0xffffffff>
    at ObjCRuntime.Dlfcn:_dlopen <0x00026>
    at ObjCRuntime.Dlfcn:dlopen <0x00010>
    at Xamarin.PreBuilt.iOS.Applications:LoadFrameworks <0x0009e>
    at Xamarin.PreBuilt.iOS.Applications:Main <0x00202>
    at <Module>:runtime_invoke_direct_void_string[] <0x00092>
 =================================================================
    
 Thread started: <Thread Pool> #4
 Thread started: <Thread Pool> #5
 Thread started: <Thread Pool> #6
 Thread started: <Thread Pool> #7
 The app has been terminated.




dotnet-xamarin
· 17
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It appears as though it is a problem with the installation / code for Firebase Messaging. If I remove everything related to it (Nuget package and associated code), the app loads OK.

1 Vote 1 ·

It appears as though it is a problem with the installation / code for Firebase Messaging. If I remove everything related to it (Nuget package and associated code), the app loads OK.

Did you use the Xamarin.Firebase.iOS.CloudMessaging package? To set up a Firebase Cloud Messaging Client App on iOS, you could following this link. Please make sure the configurations are all correct.

Related case link: https://stackoverflow.com/a/60001529/11083277

0 Votes 0 ·

It now appears to be that it is the "Hot Reload" method that does not seem to work properly?

The app loads fine if I run it in a simulator on a Mac (but I develop on Windows), however if I run it on my iPhone connected by USB (via iTunes?) then the line

             Messaging.SharedInstance.Delegate = this;

does not work. Messagaing.SharedInstance is null, so the above assignment fails.

0 Votes 0 ·
Show more comments

It now appears to be that it is the "Hot Reload" method that does not seem to work properly

To enable XAML Hot Reload for Xamarin.Forms, the Linker needs to be set to "Don't Link" or "Link None". To use XAML Hot Reload with a physical iOS device, we also have enable the Mono interpreter option or add --interpreter to the Additional mtouch arguments options for the iPhone configuration.

Check the doc: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/hot-reload#enable-xaml-hot-reload-for-xamarinforms

0 Votes 0 ·

As per the screen capture posted recently, I have those options enabled.

Hot Reload / running the app via iTunes / USB does work ... but the Firebase Cloud Messaging stuff fails. Specifically, this code Messaging.SharedInstance.Delegate = this

If I comment that out, the app runs, but the Firebase stuff does not seem to work - I don't get a fcm token.

0 Votes 0 ·

I get this in the Debug window, it appears to be unable to find 3 assemblies

What's the checked option of Linker in your project? The default setting is Link SDK assemblies only when your IDE targets iOS devices. In this mode, the linker will leave your assemblies untouched. Try to set the Linker to Don't Link in debug model for your project.

Check the doc: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=windows#linker-behavior

0 Votes 0 ·

It was already set to "Don't Link"

99009-2021-05-24-09-08-38-window.png


0 Votes 0 ·

To test the connection with my physical iPhone, I created a new Xamarin Forms solution, compiled it as is (no changes) and debugged it on my iPhone. The app loaded and runs OK.

So, something in my solution is stopping my app from starting. I have put breakpoints all over the place (main.cs and AppDelegate.cs, as well as AppShell.xaml.cs and App.xaml.cs) but none of them are hit. So, either the debugger is not attaching, or something goes wrong before the app gets started?

0 Votes 0 ·

0 Answers