title: ReactNative Swift component: how to set the constructor
body: <p>I have been working on a ReactNative project for a week now, and I want to make my own Objc/Swift native component.</p>
  
  <p>I followed the official documentation but I find it not that detailed. I can use a callback etc, and <a href="http://carminedimascio.com/2016/01/create-a-react-native-custom-swift-component/" rel="noreferrer">I also followed this</a>, but I can't find what I want.</p>
  
  <p>I want to use the constructor init() of my Class, but everytime I compile, the app launches and Xcode throws the following error:</p>
  
  <p><code>fatal error: use of unimplemented initializer 'init()' for class 'myProject.MyModule'</code></p>
  
  <p>I've tried many things such as adding <code>@objc</code> in front of <code>init()</code>, but nothing works. I'm kinda lost.</p>
  
  <p>My files (I am using Swift 3):</p>
  
  <p><strong>MyModule.m</strong>:</p>
  
  <pre class="lang-c prettyprint-override"><code>#import &lt;React/RCTBridgeModule.h&gt;
  
  @interface RCT_EXTERN_MODULE(MyModule, NSObject)
  
  RCT_EXTERN_METHOD(aMethod:(RCTResponseSenderBlock)callback)
  
  @end
  </code></pre>
  
  <p><strong>MyModule.swift</strong>:</p>
  
  <pre class="lang-swift prettyprint-override"><code>import Foundation
  @objc(MyModule)
  class MyModule: NSObject {
  
    var myFirstString: String = ""
  
    init(myString: String) {
  
      self.myFirstString = myString
  
      super.init()
    }
  
    @objc func aMethod(_ callback: RCTResponseSenderBlock) -&gt; Void {
      callback([NSNull(), self.myFirstString])
    }
  }
  </code></pre>
  
  <p><strong>MyModule-Bridging-Header.h</strong>:</p>
  
  <pre class="lang-c prettyprint-override"><code>#import &lt;React/RCTBridgeModule.h&gt;
  </code></pre>