Search code examples
iosxamarinmaui

Tethered iOS App Terminates Seconds After Debugger Pauses (Visual Studio Avalonia/Xamarin/Maui)


I'm developing a cross-platform app using Avalonia (written in C#, works similar to Xamarin / Maui). The app targets iOS, Android, & Windows, and is working well under all 3. Development is being done from Visual Studio on Windows (so for iOS, VS is paired to a remote Mac, and debugging is done on a physical iPhone that's plugged into that Mac).

The issue I'm facing: whenever I pause the debugger when running on iOS, it works (as in I can see variable values etc), but if I pause for any more than a few seconds, it kills the app. Visual Studio outputs "The app has been terminated". This makes it pretty much impossible to debug.

Is there a way to have it not kill the app seconds after it pauses in the debugger?


Solution

  • Got the answer here; apparently it can't be avoided. Complete answer:

    This is unfortunately a "feature" of iOS: if an app takes too long to launch, it's terminated (the timeout is 20s). This means that using the debugger in the launch sequence of the app is not ideal, since if you pause the app for more than a few seconds it will likely run into the 20s timeout. At the moment we don't have a way to avoid this, the best way to around it is to delay debugging until after the app has launched (technically this is measured by iOS as "returned from the AppDelegate's FinishedLaunching method: once that's done, you should be good).