3

I recently tried to implement Microsoft.AppCenter.Crashes to help track down crashes in my team's Xamarin.Forms app. However, when a crash happens on our iOS project, AppCenter never detects it. I've created the following function for setup and checking, which gets called near the start of our central project's App.xaml.cs App constructor:

private async Task CheckForPreviousCrash()
    {
        //Setup AppCenter
        await Xamarin.Forms.Device.InvokeOnMainThreadAsync(() =>
        {
            //Keys changed in StackOverflow post for security reasons.
            AppCenter.Start("ios=########-####-####-####-############;android=########-####-####-####-############;uwp=########-####-####-####-############", typeof(Crashes));
            AppCenter.IsNetworkRequestsAllowed = false; //Prevents sending user data to Microsoft. Required by company
        });

        //Make sure AppCenter is working
        bool isEnabled = await Crashes.IsEnabledAsync();
        if (!isEnabled)
        {
            _logger.LogError("AppCenter could not be started");
        }
        else
        {
            //Check for memory leak warnings
            bool memoryIssue = await Crashes.HasReceivedMemoryWarningInLastSessionAsync();
            if (memoryIssue)
            {
                _logger.LogError("AppCenter detected a memory warning in the last session");
            }

            //Check for crash info
            bool crashed = await Crashes.HasCrashedInLastSessionAsync();
            if (crashed)
            {
                var report = await Crashes.GetLastSessionCrashReportAsync();
                _logger.LogCrashReport(report);
            }

            //If AppCenter detected no issues in the last session, log an "all clear" message
            if (!memoryIssue && !crashed)
            {
                _logger.LogInformation("AppCenter did not detect a crash in the last session");
            }
        }
    }

I've tested this code using the Crashes.GenerateTestCrash() function, one of the crashes my team is trying to resolve, and a simple recursive function that calls itself forever. When run on iOS, our logs will always show the "AppCenter did not detect a crash in the last session" message, regardless of if a crash occurred. Any help determining what could be causing this would be appreciated.

Notes:

  • The iOS project is always run without a debugger attached. I'm aware of the rule that crash reports will not be generated if iOS has a debugger attached
  • This has been seen when built using both Debug and Release mode
  • This code works as expected on our Android and UWP projects
  • The iOS project always passes the isEnabled check
  • This is running AppCenter and AppCenter.Crashes version 4.5.0
  • This is running on a 7th gen iPad on iOS 15.2.1

EDIT: Extra notes in response to a suggested answer:

  • The Mac used to build the iOS project is running macOS 11.6.2
  • Project is built using XCode 13.2.1
  • The Xamarin Forms project is built in Visual Studio 2019 16.11.7, and sent to the connected mac via Visual Studio's "Pair to Mac" feature
  • There are no other libraries used for crash reporting (the closest used is Serilog, which should only be handling logging)
  • We do not use CocoaPods to integrate AppCenter
  • Please make sure that you added App Center NuGets to both Xamarin.iOS and shared projects and call the App Center start from the [correct place](https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/xamarin#423-xamarinforms). Also please see [this docs](https://learn.microsoft.com/en-us/appcenter/sdk/troubleshooting/xamarin#crashes-dont-show-up-in-the-portal) about troubleshooting for Xamarin apps – Anastasia Feb 22 '22 at 10:26
  • Did you ever get this solved? Having the same issue. Xamarin IOS wont send crashes to App Center. – Tronald Apr 01 '22 at 17:37
  • @Tronald Unfortunately no. We've been able to get reports, but have no exception details or stack traces, which makes them basically pointless. – Mark Weinhold Apr 01 '22 at 21:18

2 Answers2

0

You can check if you meet the requirements as following shows:

-Your iOS project is set up in Xcode 11 or later on macOS version 10.14.4 or later.

-You're targeting devices running on iOS 9.0 or later.

-You're not using any other library that provides Crash Reporting functionality (only for App Center Crashes).

-If you are using CocoaPods to integrate App Center, you need CocoaPods version 1.10 or later.

App Center SDK Analytics and Crashes are compatible with Mac Catalyst via XCFramework or SwiftPM.

Here are more detail about appcenter crashed on ios https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/ios

Adrain
  • 1,946
  • 1
  • 3
  • 7
  • I've double checked all of these requirements, and updated the post with the relevant info. It looks like our project meets all of them. Do you know if there's any other requirements that might need to be met? – Mark Weinhold Feb 08 '22 at 15:04
  • maybe the app’s symbols aren't uploaded to App Center or Bitcode is enabled. Details for uploading symbols are available at https://learn.microsoft.com/en-us/appcenter/diagnostics/iOS-symbolication – Adrain Feb 09 '22 at 06:48
0

Are you using the Xamarin.Google.iOS.MobileAds? If yes, the version needs to be 7.27.0.3 or earlier, because the AppCenter Crashes report is not working with latest versions of this package.