title: How to bridge React Native Promise to Swift
body: <p>Hi fellow software enthousiasts,</p>
  
  <p>I am currently working on a React native project for which I need to add some logic which has been written in swift. I am able to trigger a basic swift function through the bridging to Objective C an then to Swift.</p>
  
  <p>The problem occurs when I try to do something with promises. The page I describing this is clear on the Objective C part for Promises and also for bridging to Swift, but not so on promises to swift: <a href="https://facebook.github.io/react-native/docs/native-modules-ios.html" rel="noreferrer">https://facebook.github.io/react-native/docs/native-modules-ios.html</a></p>
  
  <p>This is what I have:</p>
  
  <p><strong>Project-Bridging-Header.h</strong></p>
  
  <pre><code>#import &lt;React/RCTBridgeModule.h&gt;
  </code></pre>
  
  <p><strong>MyLoginBridge.m</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;React/RCTBridgeModule.h&gt;
  
  @interface RCT_EXTERN_REMAP_MODULE(MyCustomLoginJSName, MyLoginModule, NSObject)
  
  RCT_EXTERN_REMAP_METHOD(loginWithEmail,
                      resolver:(RCTPromiseResolveBlock)resolve
                      rejecter:(RCTPromiseRejectBlock)reject)
  
  RCT_EXTERN_METHOD(testMethod)
  
  @end
  </code></pre>
  
  <p><strong>MyLoginModule.swift</strong></p>
  
  <pre><code>import Foundation
  
  @objc(TripleASDKModule)
  class TripleASDKModule: NSObject {
  
    @objc
    func loginWithEmail(resolver resolve: RCTPromiseResolveBlock,  rejecter reject: RCTPromiseRejectBlock) -&gt; Void {
      resolve("This method is troublesome")
    }
  
    @objc func testMethod() -&gt; Void {
      print("This Does appear")
    }
  }
  </code></pre>
  
  <p>When i trigger the testMethod, the print is shown in Xcode, so that swift code is executed. But when I call the loginWithEmail method, I get the infamous red React Native error screen saying:</p>
  
  <pre><code>Exception 'resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject is not a recognized Objective-C method.' was thrown while invoking loginWithEmail on target MyCustomLoginJSName with params (
      30,
      31
  )
  </code></pre>
  
  <p>And for the sake of completeness, the Javascript side:</p>
  
  <pre><code>const loginWithEmail = () =&gt; NativeModules.TripleA.loginWithEmail()
      .then(result =&gt; console.log(result));
  </code></pre>
  
  <p>I tried almost all variations of <code>RCT_EXTERN_REMAP_METHOD</code> and the like I could find, both with and without Remapping repeating the name, etc.
  So if this problem sound familiar, or you could guide me in the right direction, please do so, any help is appreciated.</p>