title: Compile Time Incredibly Slow
body: <p>My project consists of ~350 Swift files and ~40 cocoa pod dependencies.  </p>
  
  <p>As soon as the entire project was migrated to <code>Swift 3</code>, build times have been <strong>INCREDIBLY</strong> slow and took a little over 3 minutes to completely compile.<br>
  I've noticed that if I rebuild after not changing any files, it builds within a reasonable amount of time. However, if I add a new function, it takes the 3+ minutes.<br>
  Cocoapods does not seem to be causing the problem as it delays on <code>Compiling Swift source files</code> state.</p>
  
  <p>I followed <a href="http://irace.me/swift-profiling" rel="noreferrer">this</a> to investigate:</p>
  
  <ol>
  <li><p>Added the <code>-Xfrontend -debug-time-function-bodies</code> flag to my <code>Other Swift Flags</code> in my target's build settings</p></li>
  <li><p>Build the project</p></li>
  <li><p><a href="https://i.stack.imgur.com/ENExM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ENExM.png" alt="enter image description here"></a></p></li>
  <li><p><a href="https://i.stack.imgur.com/2WHu0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2WHu0.png" alt="enter image description here"></a></p></li>
  <li><p>Copied this into terminal and ran <code>pbpaste | egrep '\.[0-9]ms' | sort -t "." -k 1 -n | tail -100</code></p></li>
  </ol>
  
  <p>However, I didn't see anything of concern. The file that took the longest to compile was only 250ms. The next closest was 100ms, even if all 350 files took 250ms to compile, that would only be a total of 73 seconds which is way off from the 3+ minute builds I am seeing.  </p>
  
  <p><br/></p>
  
  <h3>What could be causing these long compile times?</h3> 
  
  <p>It was never as slow before updating to <code>Xcode 8</code> and <code>Swift 3</code>.</p>