title: Swift -Ounchecked and Assertions
body: <h1>Preface</h1>
  
  <p>In Swift, <code>ENABLE_NS_ASSERTIONS</code> is ignored, and whether assertions are on or off is dependent of <code>SWIFT_OPTIMIZATION_LEVEL</code>, <a href="http://blog.krzyzanowskim.com/2015/03/09/swift-asserts-the-missing-manual/" rel="noreferrer">see here for more information</a>.</p>
  
  <ul>
  <li><code>assert()</code> is active for <code>-Onone</code></li>
  <li><code>assertionFailure()</code> is active for
  <code>-Onone</code></li>
  <li><code>precondition()</code> is active for <code>-Onone</code> and <code>-O</code></li>
  <li><code>preconditionFailure()</code> is active for <code>-Onone</code>, <code>-O</code> and <code>-Ounchecked</code></li>
  <li><code>fatalError()</code> is active for <code>-Onone</code>, <code>-O</code> and <code>-Ounchecked</code></li>
  </ul>
  
  <h1>What I want to achieve</h1>
  
  <p>Debug and Beta Builds should have assertions <strong>enabled</strong>, Release Builds should have assertions <strong>disabled</strong>.</p>
  
  <h1>How I could do it</h1>
  
  <p>I could write all my assertions in Swift via the <code>precondition</code> method and compile Release builds with the <code>-Ounchecked</code> flag, beta builds with the <code>-O</code> flag.</p>
  
  <h1>What I'm unsure about</h1>
  
  <p>The default in iOS for Release builds is <code>-O</code>. Is there anything advised against using <code>-Ounchecked</code> for release builds? Which other unwanted side effects could this cause?</p>