Tertium Tertium - 5 months ago 85
iOS Question

Human-readable exception handling in Xamarin.iOS release Appstore app

Is there any "standard" and automated way to get stack traces from Xamarin.iOS release Appstore app?

It's been a long time ago when I wrote native iOS 4.0 apps in Xcode, there was a huge problem to get exception stack traces from release binary: apps sent non-symb stacks to my server, I downloaded them, parsed dSYM files and replaced addresses with real methods. Even wrote java helper for that. But it was a fragile construct (several architectures, updating binary format, etc.) and long ago I've found it doesn't work correctly anymore. It was not needed and I've just forgot.

In android and Win/Wp I get managed stacks, as I need to know about errors primarily in my C# code.

But now I write an app using Monogame and Xamarin.iOS in VisualStudio:

AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
Ut.saveStringToFile("exceptions.log", args.ExceptionObject.ToString());
};


But in Xamarin.iOS app I've found that I can't have stacks just out of the box: even on simulator in release some lines are removed (though I've turned off LLVM and optimisations in release build) others point to some addresses.

How modern programmers get stacks from Xamarin.iOS apps? Without hidden apis (I plan to post app to Appstore) and testflight (using third-party services can be too expensive nowadays for free app owner).

Answer

Surprisingly it's quite enough:

        try
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                Exception e = args.ExceptionObject as Exception;
                String s = (e!=null) ? ("Error Handled: " + e.Message + "\n" + e.StackTrace) :
                    ("Error Handled (not Exception): " + args.ExceptionObject.ToString());
                Ut.saveStringToFile("exceptions.log", s);

            };
        }
        catch (Exception)
        {
        }

And in project settings (at least that I've done for adhoc build): iOS Build-> enable debugging, Build->Optimize code = off, Build->Advanced->DebugInfo = Full.

In exceptions.log after crash I get stack trace with line numbers. I've played with Hockeyapp with those debug settings off, but providing dSym. No idea why should I use hockey app (even for free) when it produces the same stacks like simple handler does. My self-written online bugtracker is simpler than huge msft construct but can store/search/sort stacks as well. There is no miracle. Alas.

Still the question is: how can I see line numbers in stacks of release AdHoc/AppStore binary? (dSym handles only native code, debug info about managed code is in pdb)