title: Swift code not called by obj-c with bridge header
body: <p><strong>Issue:</strong></p>
  <p>I'm trying to build a bridge between Swift and Unity, in order to achieve that I need to create a bridge between Swift and Obj-C and call Obj-C code from Unity. I can now build and run the generated Unity Xcode project, and the Obj-C code can be called from Unity without an issue. But when I try to call Swift code from Obj-C, the Swift code doesn't seem to be ever called (I put a <code>print(&quot;abc&quot;)</code> in Swift code but nothing appears in the console).</p>
  <p><strong>What I did</strong></p>
  <p>Basically following <a href="https://medium.com/@kevinhuyskens/implementing-swift-in-unity-53e0b668f895" rel="nofollow noreferrer">this</a> article, in short:</p>
  <ol>
  <li>Create a framework in Xcode, add a swift class and mark codes I wanted to expose to Obj-C as <code>@obj public</code></li>
  <li>Under the framework add a <code>.mm</code> Obj-C file that calls Swift code, to achieve that it need to include the generated <code>&lt;MODULE_NAME&gt;-Swift.h</code> header file.</li>
  <li>Create a <code>&lt;PROJECT_NAME&gt;-Bridging-Header.h</code> to bridge the 2 code files.</li>
  <li>Compile the code, put the 3 files in Unity's iOS plugin folder (Assets/Plugin/iOS/&lt;PROJECT_NAME&gt;), add a c# script that calls the Obj-C code and a postprocess file to adjust Xcode settings when building the iOS project.</li>
  <li>Put the generated <code>&lt;PROJECT_NAME&gt;.framework</code> folder in Assets/StreamingAssets.</li>
  <li>Build the iOS project in Unity, open the <code>Unity-iPhone.xcodeproj</code>.</li>
  <li>Drag <code>&lt;PROJECT_NAME&gt;.framework</code> from <code>/Data/Raw</code> to <code>/Frameworks</code>, add it to the Unity-iPhone and UnityFramework target, changed the target membership for both to optional.</li>
  <li>Run the Unity-iPhone xcode project, Obj-C code can be called via Unity C# code, but the Swift code is not called.</li>
  </ol>
  <p><strong>My thoughts</strong></p>
  <p>In the Obj-C file it included a <code>&lt;MODULE_NAME&gt;-Swift.h</code> header file that describes the exposed Swift class functions, in theory that should be auto-generated by the Unity-iPhone project, but I have to drag the previously generated <code>&lt;PROJECT_NAME&gt;.framework</code> to the <code>/Frameworks</code> group in Unity-iPhone project for the Obj-C file to reference otherwise there will be a module not found issue. So there're actually 2 <code>&lt;MODULE_NAME&gt;-Swift.h</code> files in Unity-iPhone project, one in the <code>&lt;PROJECT_NAME&gt;.framework</code> and another one in <code>UnityFramework.framework</code> which is one of the products of the Unity-iPhone project. In <code>Bridge.mm</code> if I cmd+click on the reference to <code>-Swift.h</code>, it goes to the <code>-Swift.h</code> file in the framework in <code>/Framework</code> group. Then in the <code>-Swift.h</code> there's a definition of the Swift class like this:</p>
  <pre><code>...
  SWIFT_CLASS(&quot;_TtC11&lt;MODULE_NAME&gt;12&lt;CLASS_NAME&gt;&quot;)
  @interface CLASS_NAME : NSObject
  ...
  </code></pre>
  <p>If I cmd+click on the class, it refers me back to the actual swift class in the plugin, which is correct, but actually it's not calling the Swift code at all...
  Maybe the Obj-C is not calling the correct Swift code? Or it get confused? Maybe some build settings not set correctly in the postprocess? I'm not seeing any error from the console, the call just failed silently, any ideas on how to fix it?</p>