Report native iOS errors with Raygun’s new beta Xamarin providerPosted Oct 9, 2014 | 4 min. (768 words)
If you’re a Xamarin iOS developer then we have got some great news for you.
Today we are announcing the open beta of a new Raygun Xamarin iOS provider that has the added capability of reporting native iOS errors, meaning you can now get even more insights into your Xamarin apps. Native errors can occur within native iOS frameworks that you’ve bound into your managed Xamarin iOS applications. They can also occasionally occur within the native core of the Xamarin framework, so we recommend that you all try this out.
This provider of course still functions exactly the same as the existing Raygun Xamarin iOS provider when it comes to managed exceptions. Once the beta is over, the native error reporting functionality will be included in the existing provider available via NuGet and the Xamarin Component store.
How to report native iOS errors
The beta version of this new provider is being made available as a dll which you can download here. If you are using the existing Raygun Xamarin iOS provider via NuGet or the Xamarin Component store, simply uninstall it for now and reference the dll into your project.
Just like the existing provider, Raygun can be set up with a single line of code. This is done by making a call to the static RaygunClient.Attach method. By default, this will not enable native error reporting to maintain the existing behavior. To enable native error reporting, use one of the new Attach method overloads that takes a couple of boolean parameters.
Mindscape.Raygun4Net.RaygunClient.Attach("YOUR_APP_API_KEY", true, true);
The first boolean parameter is to indicate whether or not to enable native iOS error reporting.
The second boolean parameter is whether or not to hijack some of the native signals – this is to solve the well known iOS crash reporter issue where null reference exceptions within a try/catch block can cause the application to crash. By setting the second boolean parameter to true, the managed code will take over the SIGBUS and SIGSEGV iOS signals which solves the null reference issue. Doing this however prevents SIGBUS and SIGSEGV native errors from being detected, meaning they don’t get sent to Raygun. This is why we provide this as an option – so if you don’t have any issues with null reference exceptions occurring within try/catch blocks and you want to maximize the native errors that you can be notified of, then set the second boolean parameter to false.
Now Raygun can report native errors occurring in your managed Xamarin iOS apps. Note that it is unsafe to send native errors at the time an app has crashed, and so native reports are first saved to the device and then sent the next time the app starts up. Managed exceptions however will still be sent instantly.
Upload your dSYMs
For those who don’t know, dSYMs are essential for getting good stack traces out of native iOS error reports. They contain information about how to symbolicate the crash report to get the original class name, method name, file name and line number of each stack trace frame. Raygun does this symbolication process for you when you upload the equivalent dSYM.
Note that a new dSYM is generated for every build, so make sure you always upload the latest dSYM for builds that you need to debug with Raygun. To do this, build your project, and then navigate to the bin directory of your Xamarin iOS project and find the dSYM file that Xamarin generates. Next, from your Raygun dashboard, click “Application Settings” in the side bar, and then click “dSYM Center” that appears below it.
Finally zip the dSYM and drag it onto the drop pad. Now, new errors that pump into your Raygun dashboard will be symbolicated against the dSYM and display a nice stack trace. Or for existing errors that were sent before you uploaded the dSYM, hit the “Reprocess crash report” button on the exception page in Raygun to perform the symbolication.
Try it today
Whether you’re an existing Raygun user, or you want to get insights on how well your Xamarin iOS apps are doing in the wild, try out the improved Raygun Xamarin iOS provider with native error reporting. Download the beta here. If you have any feedback or questions about this beta, please leave a comment on this blog post, or head over to the forums.
Sign up for the free 14 day trial of Raygun – no credit card required.