title: Class extensions leaking to framework's public API in Swift submodules
body: <p>I have a Swift-only project that builds a framework. The project has 3 targets:</p>
  
  <ul>
  <li><p>Core: static library (libCore.a), defines module <code>Core</code></p>
  
  <pre class="lang-swift prettyprint-override"><code>// core.swift
  public struct CoreStruct {}
  public func coreFunc() {}
  </code></pre></li>
  <li><p>Ext: static library (libExt.a), defines module <code>Ext</code></p>
  
  <pre class="lang-swift prettyprint-override"><code>// ext.swift
  import Core
  public extension CoreStruct {
      public func internalStuff() {}
  }
  public func extFunc() {}
  </code></pre></li>
  <li><p>MyFramework: Cocoa dynamic framework that is linked with <code>libCore.a</code> and <code>libExt.a</code></p></li>
  </ul>
  
  <p>Now, I want the public interface of <code>MyFramework</code> to only expose Core because the stuff in <code>Ext</code> is implementation detail that should only be visible to <code>MyFramework</code>. So I added this to the umbrella header:</p>
  
  <pre class="lang-c prettyprint-override"><code>// MyFramework.h
  ...
  @import Core;
  </code></pre>
  
  <p>At this point, <code>CoreStruct</code> and <code>coreFunc()</code> are visible to consumers of <code>MyFramework</code>. The problem is that so is <code>CoreStruct.internalStuff()</code>! But, interestingly enough, <code>extFunc()</code> is not! So it appears that extensions behave somewhat differently to regular functions when it comes to access control.</p>
  
  <p>I have already tried creating custom modulemap files, like so:</p>
  
  <pre><code>// MyFramework.modulemap
  framework module MyFramework {
    umbrella header "MyFramework.h"
    export *
    module Core { export * }
  }
  
  // MyFramework.private.modulemap
  explicit module MyFramework.Ext {
    export *
  }
  </code></pre>
  
  <p>but it didn't change anything.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>how can I make <code>Ext</code>'s extensions available to <code>MyFramework</code> but hidden from the world?</li>
  <li>is the exposure of <code>internalStuff()</code> a bug or a feature?</li>
  </ol>