Strange Issue 'Cannot Find Type 'Rctresponsesenderblock' in Scope' on Swift Module React Native

I have a very strange problem: "Can't find the type RCTResponseSenderBlock in scope." It's strange, because in one case it is there and in the other it doesn't, looks like a bug.

This is screenshot issue.

This my Objective-C file:

#import <Foundation/Foundation.h>
#import "React/RCTBridgeModule.h"
#import <React/RCTEventEmitter.h>
#import <React/RCTConvert.h>

@interface RCT_EXTERN_MODULE(BLEclass, NSObject)

RCT_EXTERN_METHOD(addEvent:(NSString *)name callback:(RCTResponseSenderBlock)callback )

@end

And this my Swift file, where i have issue :

import Foundation

@objc(BLEclass)
class BLEclass: NSObject{
  @objc(addEvent:callback:)
    func addEvent(_ name: String,_ callback:RCTResponseSenderBlock){
      NSLog("%@", name);
      let resultsDict = [
           "name" : name
           ];
      callback([NSNull(),resultsDict])
     }
}

If you know how to fix it, please write answer.

Thanks.

2 Answers

I had this same issue and discovered I had to add the import to my main bridge file.

#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>

I out which file was set by looking at the Build settings under Swift Compiler - General -> Objective-C Bridging Header which appears to be the default for the app.

2

I resolved the issue by adding

#import <React/RCTViewManager.h>
#import <React/RCTConvert.h>
#import <Foundation/Foundation.h>

to Pods>Development Pods>react-native-rsa-native>RNRSA-Bridging-Header

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest