xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.42k stars 507 forks source link

Prevent app from being killed on debugger break (tethered iOS) #20716

Closed metal450 closed 2 weeks ago

metal450 commented 2 weeks ago

Apologies in advance if this is the wrong place to post - I imagine the issue is something in iOS, but I've searched & posted in a variety of places without avail, and was directed here as a possibility.

I've got a cross-platform Xamarin app (iOS, Android, & Windows). Development is from Visual Studio on Windows (so for iOS, VS is paired to a Mac, into which a physical iPhone is plugged).

Debugging on the tethered iOS works (as in I can break & see variable values etc). But just a few seconds after I break, it always kills the app. Visual Studio outputs "The app has been terminated". This makes it pretty much impossible to debug.

Is there a way to prevent the app from being killed whenever the debugger pauses/breaks?

rolfbjarne commented 2 weeks ago

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).

metal450 commented 2 weeks ago

Ah, bummer - but thanks for the quick reply.