4

I have a beta iOS app that is distributed to testers through TestFlight. Sometimes these testers encounter an error that doesn't trigger a crash, but results in a degraded experience. I log all of these errors using os_log with the error log level, but I'm not sure how to retrieve the logs unless I physically attach their device and view the logs in Console.

For example, the app might encounter an unknown error when creating an account. The app shows an alert notifying the user that an error occurs and then logs the details of the error with os_log.

import UIKit
import os.log

class MyViewController: UIViewController {
    func signUpButtonTapped() {
        do {
            // Try to create the user's account, which might throw an exception.
            try createUserAccount()
        } catch {
            os_log("Unknown sign up error: %@", log: .default, type: .error, String(describing: error))

            let alert = UIAlertController(title: "Sign Up Error", message: "There was an error creating your account.", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "OK", style: .default))
            present(alert, animated: true)
        }
    }
}

Is it possible to retrieve these logged error messages through TestFlight? Alternatively, is there a built-in way for testers to manually send me the app's logs? I've only come across ways of retrieving crash logs, which doesn't work because the error doesn't trigger a crash.

I'm aware that there are 3rd party services/libraries that can accomplish this, but I'd prefer to not add another dependency.

Greg
  • 3,731
  • 1
  • 29
  • 25

1 Answers1

1

It looks like there's no way to remotely retrieve logs from TestFlight user.

I did find a way for users to manually send logs with sysdiagnose, but it's a bit cumbersome. The details are documented by Apple here (you must be signed into an Apple developer account to view the link). I'm following the same steps as another answer that goes over how to retrieve os_log messages.

The basic steps are:

  1. Ask the user to simultaneously press and release both volume buttons and the side (or top) button for 1 to 1.5 seconds.

  2. Wait up to 10 minutes for the diagnostic gathering to complete.
  3. Go to: Settings.app > Privacy > Analytics > Analytics Data
  4. Scroll all the way down until you see items starting with "sysdiagnose". The filename will contain the date/time and look something like "sysdiagnose_YYYY.MM.DD_HH-MM-SS-XX".
  5. Tap the sysdiagnose file. It will show a blank screen with a share button in the top right.
  6. Tap the share button (or sync with iTunes) to send the logs. The file will be large (around 300 MB), so you'll need to AirDrop it or find another way to send it. Email won't work due to the size.
Greg
  • 3,731
  • 1
  • 29
  • 25