title: Error message '_BSMachError: (os/kern) invalid capability (20)'
body: <p>Please note that this error message is pretty low level, so it crops up for different reasons in different scenarios.  If you have a scenario that isn't mentioned in one of the answers below, please consider adding your situation as well, so maybe this could be a central answer for various situations that raise this error message.</p>
  
  <p><strong>Edit Nov 10, 2015</strong> Also note, I marked my own answer as the answer, but that was before anyone else had posted.  I guess none should really be marked as the answer, because as we've now seen below... this error doesn't have just one answer because it's so low level.</p>
  
  <p>I'm running</p>
  
  <ul>
  <li>iOS 9.0 Simulator</li>
  <li>XCode 7.0</li>
  </ul>
  
  <p>Everything was working fine yesterday.</p>
  
  <p>Today, after a bunch of work on rotation related stuff, I started getting this error in my console output when I run the app in the Simulator and I rotate it.</p>
  
  <blockquote>
    <p>_BSMachError: (os/kern) invalid capability (20)</p>
    
    <p>_BSMachError: (os/kern) invalid name (15)</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/DhBqb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DhBqb.png" alt="Screenshot for this issue"></a>
   - I've cleared my build folder,
   - I've cleaned the derived data folder,
   - I've reset the simulator.</p>
  
  <p>I was working with </p>
  
  <ul>
  <li><code>UIViewController viewWillLayoutSubviews</code></li>
  <li><code>UIViewController viewWillTransitionToSize:...</code></li>
  </ul>
  
  <p>I was also checking various 'Drawing' settings on the Attributes Inspector in IB.</p>
  
  <p>I also made a utility category on UIView where I created a bunch of methods that create <code>CGRect</code>'s and helps me assign frames to views.</p>
  
  <p><a href="https://i.stack.imgur.com/5YFqR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5YFqR.png" alt="Root View Controller"></a></p>
  
  <p><a href="https://i.stack.imgur.com/K7b3E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/K7b3E.png" alt="Root View Controller Settings"></a></p>