crash-report-assert 1.0.1

crash-report-assert 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Dec 2014

Maintained by Esteban Torres.



  • By
  • Esteban Torres

Custom assertion

Thanks to the article by Mike Ash (see legal at the bottom) I came to the realization that the assertions provided by default although good in principle lack a lot of potential and decided that a better one could be done with some simple tweakings from the code in the article.
For this I created a "custom" assertion that also supports the use of CocoaLumberjack and has a "hack" to throw exceptions when the assertion fails (instead of just aborting).

The assertion has a couple of possible "configurations" explained below.

Features supported

  • Assertion supports the use of CocoaLumberjack [GitHub Repo] for more detailed logging.
    • In order to use it you need to set the PREPROCESSOR macro USE_LUMBERJACK=1 and configure the loggers for CocoaLumberjack (demo app does this)
  • Assertion also supports a "hack" to make the assertion reach the CrashReport via a flag that will output the assert as an exception.
    Note: The "extra" data will just appear in the CrashReport pointing to the line where the assertion was called.
    • To do this specify the PREPROCESSOR macro kSHOULD_THROW_EXCEPTION=1 and this will make the assertion to build a "custom" exception with the following data:
      • Message: Assertion Failure - #expression
      • Reason: #expression
      • User Info:
        • File: File name where the assertion failed
        • Line: Line number on the file where the assertion failed
        • Function: The name of the function where the assertion failed
        • Message: The custom message provided to the assertion (if any)

To-Do

  • Add support for FlurrySDK (Logging the custom exception to Flurry as a way to reach all the possible data)
  • Add support for Crittercism (Same as FlurrySDK)
  • Add an automatic way of sending the CocoaLumberjack logs compressed to a desired location

Legal

Based on an article by Mike Ash - Friday Q&A 2013-05-03: Proper Use of Asserts

Icon was taken from IconFinder.com
And used under this license

License

This code is under the GNU GPL License attached to the repository. Link to file here.