'React Native Module cannot find type RCTPromiseResolveBlock not in scope
I am new to building modules in react native and trying to build a native module with react native module, for some reason I get. I have googled online and it says just add the imports to your bridging file to expose object-c code to swift but seems its not happening for me. not sure if i missed something or i am missing something.
cannot find type 'RCTPromiseRejectBlock' in scope
cannot find type 'RCTPromiseResolveBlock' in scope
I included <React/RCTBridgeModule.h> in my AppName-Bridging-Header.m file but still same result, i have removed all node_modules, podfile and rebuild and still same problem.
# App-Bridging-Header.m
#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>
#import <React/RCTConvert.h>
ModuleFile.m
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTConvert.h>
@interface RCT_EXTERN_MODULE(Vgas, NSObject)
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
@end
#swift file
import Foundation
@objc(Vgas)
class Vgas: NSObject {
@objc(multiply:withB:withResolver:withRejecter:)
func multiply(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
resolve(a*b)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

