title: Intercepting crashes on iOS
body: <h1>Description</h1>
  
  <p>I would like to catch all exceptions that are occurring in iOS app and log them to file and eventually send them to back-end server used by the app.</p>
  
  <p>I've been reading about this topic and found usage of signals sent by device and handling them, but I'm not sure if it's gonna break App Store Review guidelines or it may introduce additional issues.</p>
  
  <p>I've added following to <code>AppDelegate</code>:</p>
  
  <pre><code>NSSetUncaughtExceptionHandler { (exception) in  
      log.error(exception)  
  }  
  
  signal(SIGABRT) { s in  
      log.error(Thread.callStackSymbols.prettified())  
      exit(s)  
  }  
  
  signal(SIGILL) { s in  
      log.error(Thread.callStackSymbols.prettified())  
      exit(s)  
  }  
  
  signal(SIGSEGV) { s in  
      log.error(Thread.callStackSymbols.prettified())  
      exit(s)  
  }
  </code></pre>
  
  <hr>
  
  <h1>Questions</h1>
  
  <ul>
  <li>Is this good approach, any other way?</li>
  <li>Will it break App Store Review guidelines because of usage of <code>exit()</code></li>
  <li>Is it better to use <code>kill(getpid(), SIGKILL)</code> instead of <code>exit()</code>?</li>
  </ul>
  
  <hr>
  
  <p><strong>Resources</strong></p>
  
  <ul>
  <li><a href="https://github.com/zixun/CrashEye/blob/master/CrashEye/Classes/CrashEye.swift" rel="noreferrer">https://github.com/zixun/CrashEye/blob/master/CrashEye/Classes/CrashEye.swift</a></li>
  <li><a href="https://www.plcrashreporter.org/" rel="noreferrer">https://www.plcrashreporter.org/</a></li>
  <li><a href="https://chaosinmotion.blog/2009/12/02/a-useful-little-chunk-of-iphone-code/" rel="noreferrer">https://chaosinmotion.blog/2009/12/02/a-useful-little-chunk-of-iphone-code/</a></li>
  </ul>