title: How can I capture / log a fatal error in Swift?
body: <p>For example, <code>fatal error: unexpectedly found nil while unwrapping an Optional value</code>. Regardless of the cause, can this data be captured? Is this <code>stderr</code> or something else?</p>
  
  <p><strong>Edit:</strong> I found a reference at <a href="http://swiftdoc.org/func/fatalError/" rel="nofollow">http://swiftdoc.org/func/fatalError/</a> that says the function (which I'm assuming is indeed what Swift is internally calling) "Unconditionally print a message and stop execution.". So perhaps there's nothing left to do but get ahold of the remote crash report via TestFlight crash reports or actually having the device handy.</p>
  
  <p>I'm able to log all uncaught exceptions via <code>NSSetUncaughtExceptionHandler</code> in <code>main.swift</code>, and we have good logging going on in other parts of our app wherever bad (but possible) errors can occur. I was hoping to also log these fatal errors so that our logs show a more complete picture of crashes occuring on remote testing devices. </p>