As per my understanding, when an iOS app crashes, the system creates a .crash file that can be accessed through Xcode. Is it possible to read this file programmatically from within the app itself?
My intention is to send this crash log (if exists) to a server so that we can analyse the log without user intervention. There are several crash reporting services (e.g. bugsense, crashlytics) that are able to do this, so I assume a custom implementation should be possible?
It is not possible to read an iOS system generated crash report from within your app. The reason is that your app runs in a sandbox and has no access to anything outside its sandbox. So if you try to read a file or directory from a path that is not within your sandbox, you won't get any data.
The only option to get crash reports is adding a library into your code that is able to detect crashes, create reports and send them somehow. Most send it to a server since getting thousands of crash reports via email is not very efficient, also considering the required symbolication process to get the class, method and line number information.
A popular and safe to use open source library is PLCrashReporter. Most services use this one, a few write their own functionality to achieve the functionality. There is an open source app available to compare different crash reporting services and libraries named CrashProbe (Disclaimer: I am one of its developers). The project has a website at http://crashprobe.com with a list of services already compared.
It is also important to note, that having a specific crash reporting library is not enough for good crash reports, since the symbolication process needs to be able to translate information in the crash report to point you to the correct class name, method name, file name and line number for each frame in the stack trace.
I'd recommend to compare services that seem to fit your needs (also using CrashProbe) and then decide which one is best for your use case.
I won't recommend any services, since this is not allowed according to the stackoverflow guidelines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With