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.