Skip to Content
Technical Articles
Author's profile photo Marco Eidinger

Introducing iOS Crash Reporting capabilities for apps built with SAP Cloud Platform SDK for iOS

Overview

Recently released version 6.0 of SAP Cloud Platform SDK for iOS introduces support for iOS crash reporting. Gather client crash data and upload them to SAP Cloud Platform Mobile Services, where you use analytical tools to gauge the impact on business users.

In this article, I will help you to understand

  • how to allow crash log upload in Mobile Services
  • how to collect and upload crash logs with the SDK
  • how to upload dSYM files in Mobile Services
  • how to analyze and drill down on crash information in Mobile Services

I assume you already have basic knowledge about SAP Cloud Platform Mobile Services and have access to an account. If not you can get more details and instructions about how to request a trial version in this tutorial.

Important: iOS crash reporting is only available in SAP Cloud Platform, Cloud Foundry environment!

Step 1: Allow crash log upload in Mobile Services

For existing apps, please enable Crash Log Upload in the assigned feature Mobile Client Usage and User Feedback.

Using the latest SAP Cloud Platform SDK for iOS Assistant to create a project will automatically enable it

Step 2: Collect and upload crash logs with the SDK

Initialize crash reporter

It is recommended to use SAPFioriFlows framework as initialization is handled by its DataCollectionConsentStep

In case you created your project with an older SDK version then simply replace the old UsageCollectionConsentStep with the new DataCollectionConsentStep.

Otherwise, you can initialize the crash reporter as follows:

import SAPFoundation

SAPCrashReporter.shared.initialiseCrashReporter()

Obtain user consent

It is recommended to use SAPFioriFlows framework as s obtaining user consent is handled by its DataCollectionConsentStep

In case you created your project with an older SDK version then simply replace the old UsageCollectionConsentStep with the new DataCollectionConsentStep. The new step handles user consent for usage collection + crash reporting.

Otherwise, you have to obtain user consent by yourself and can then pass the information as follows:

import SAPCommon

let userID: UUID!

CrashConsent.shared.consentForUser(
userID,
  given: true
)

CrashConsent allows you to check and revoke consent based on the given UUID.

Obtaining user consent is needed only once, normally during onboarding a new user. The information is stored on the device for subsequent sessions.

Upload crash report

The app should trigger crash upload after onboarding has been successfully completed because communication to SAP Cloud Platform Mobile Services will have then been fully established.

If you use the SAP Cloud Platform SDK for iOS Assistant to create your project structure, then the necessary code and service call are generated.

extension AppDelegate {
  private func uploadCrashReport() {
    guard let session = self.sessionManager.onboardingSession else {
      // Onboarding not yet performed
      return
    }
    guard let settingsParameters = session.settingsParameters else {
      return
    }
    // Upload crash logs after onboarding
    SAPCrashReporter.shared.uploadCrashFile(sapURLSession: session.sapURLSession,
      settingsParameters: settingsParameters)
  }
}

For existing projects, you can easily copy and paste the extension. Please make sure to call uploadCrashReport() after the user successfully onboarded.

Step 3: Upload dSYM files in Mobile Services

You might wonder why the iOS crash reports might show the memory address related to a stacktrace frame rather than the source code location.

When Xcode compiles your source code into machine code, it generates a list of symbols in your app—class names, global variables, and method and function names. These symbols correspond to the file and line numbers where they’re defined.

By default, the debug symbols are stripped when compiling a release build to reduce the size of the generated binary. Those debug symbols carry the required information to translate from a memory address to the associated source file and line number.

You need to upload your app-specific dSYM file to SAP Cloud Platform Mobile Services. If you are using 3rd party frameworks then you should also upload those dSYM files for proper symbolication.

Select the Symbol Center tab in assigned feature Mobile Client Usage and User Feedback which provides on-screen information on how to find missing symbols on your machine. Compress the dSYM file(as) as zip archives and upload them.

Good news: dSYM files for SAP Cloud Platform SDK for iOS frameworks do not need to be uploaded. They are already known to SAP Cloud Platform Mobile Services.

Step 4: Analyze crash information in Mobile Services

SAP Cloud Platform Mobile Services performs an intelligent grouping of individual crashes (with the same root cause) across devices, users, and versions.

You can view and filter for crash groups by

  • platforms
  • apps
  • versions and
  • timeframe

Charts give you a graphical representation of

  • crashes over time
  • affected users over time

For a crash group, you see the common stack trace but you are also able to drill-down to the individual crash reports to view device-specific information.

Video

Video

The video illustrates steps 3 and 4 in the SAP Cloud Platform Mobiel Services cockpit.

Summary

With this information and the SDK Version 6.0.0 (download via Developer Trials & Download page) , you are equipped to collect and upload crash reports for analysis in Mobile Services.

Please leave a question if something is not unclear.

Please like the blog post if you found the information helpful.

Appendix

Assigned tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sangamesh Kalagi
      Sangamesh Kalagi

      Hi Marco,

      Thanks for providing good useful tutorial.

      I have updated latest framework in my existing project and followed the steps which you mentioned  and enabled crash logs in cockpit.

      But crash log is not showing in cockpit and I am facing the issue like "The incoming path /mobileservices/clientdata/v1/runtime/crashlog is not mapped to a destination. Rejecting the request with 404 (not found)"

      Can you help me how to resolve this issue?

       

      Thanks in advance.

      Author's profile photo Wen-nan Chu
      Wen-nan Chu

      Hi Sangamesh,

      From the error log, it means ‘crash logs’ is not enabled in your application. I suspect that your mobile service application is still in old mode. If you can see the notification from mobile service cockpit like below:

      Please upgrade your mobile application service, ‘crash logs’ can only be supported for the latest version.

      Or you can update the application, click 'Update' while see the popup dialog box:

      So I suggest you to upgrade your mobile application service, many new features are only support for new version.

       

      Thanks and Best Regards,

      Wen-nan Chu

      Author's profile photo Sangamesh Kalagi
      Sangamesh Kalagi

      Hi Wen-nan Chu,

      Thanks for your reply.

      We have already enabled crash log in our application. In cockpit, that notification is not showing for me and it might be upgraded by one of my team.

      Can you help me where I am missing to resolve this issue "The incoming path /mobileservices/clientdata/v1/runtime/crashlog is not mapped to a destination. Rejecting the request with 404 (not found)"

       

      Thanks in advance

      Sangamesh.

      Author's profile photo Marco Eidinger
      Marco Eidinger
      Blog Post Author

      Hi Sangamesh,

      thanks for the feedback! I am very sorry to hear that the advise from Wen-nan does not help. Please open a support ticket so that our team can directly coordinate with you and help to resolve the issue.

      Kind regards,
      Marco

      Author's profile photo Sangamesh Kalagi
      Sangamesh Kalagi

      Hi Marco,

      Thanks for your reply. Before going to create support ticket we want to cross check with you if we are missing anything.

      In mobile service under "Mobile client usage and user feedback" we can see one section named "Mapping file". What is that section for? Do we need to upload any file in that section?

      Mapping%20File

      Mapping File

       

      We have already existing project with old SDK and we have followed following steps. Please let us know if we missed anything.

      1) We have  enabled Crash Log Upload in the assigned feature Mobile Client Usage and User Feedback.
      2) Downloaded latest SAP Cloud Platform SDK for Assistant v6.0.0
      3) Tried with both Xcode 12.2 and 12.3
      4) We replaced the old UsageCollectionConsentStep with the new DataCollectionConsentStep in OnboardingFlowProvider Class as mentioned in the document.

      5) Added uploadCrashReport() method and called after the user successfully onboarded.

      In Xcode console we are getting log as below even through we gave consent during onboarding.

      # SAP.Foundation.Usage.CrashReporting.PLCrashReporterAdapter - WARN - (0x60000258dcc0) - PLCrashReporterAdapter.swift.setupCrashReporting() - Crash reporting can not be enabled.

      Crash%20report%20collection

      Crash report collection

       

       

       

      Can you please help us how to resolve this issue. Thanks in advance.

      Author's profile photo Marco Eidinger
      Marco Eidinger
      Blog Post Author

      Hi Sangamesh,

      "Mapping File" is not relevant for iOS apps but are related for Android apps when using obfuscation.

      The error you mentioned now, i.e. "Crash reporting can not be enabled", might indicate that your app is already a crash reporting library (PLCrashReporter).
      If that's the case then this is problematic as our SDK is using PLCrashReporter internally and only one PLCrashReporter instance may be enabled in a process.

      Anyway, please do not hesitate to open a support ticket for MOB-SDK-IOS as my colleagues and I are eager to help out. But blog post comments are not the best and most efficient way to do do.

      Kind regards,
      Marco

      Author's profile photo Sangamesh Kalagi
      Sangamesh Kalagi

      Hi Marco,

      Thanks your reply.

      As you mentioned, we have stopped calling our crash report library in the app and facing issue like "The incoming path /mobileservices/clientdata/v1/runtime/crashlog is not mapped to a destination. Rejecting the request with 404 (not found)"

      Today we have created supporting ticket for MOB-SDK-IOS as you suggested.

       

      Thanks,

      Sangamesh.

       

      Author's profile photo Wen-nan Chu
      Wen-nan Chu

      Hi Sangamesh,

      Sorry for the late reply. I have some questions about this issue.

      1, I want to confirm that 'crash log' keeps not working or sometimes not working?

      2, Is client usage data uploading work?

      3, Could you try to create a new application for crash log testing? And check if it can work correctly?

      4, Could you provide your subaccout and space information (or cockpit access url for our investigation)?

      Please update the ticket https://support.wdf.sap.corp/sap/support/message/002075129500000844372021

       

      Thanks and Best Regards,

      Wen-nan Chu