Strange issue 'Cannot find type 'RCTResponseSenderBlock' in scope' on Swift module React Native
Asked Answered
A

3

10

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.

Allynallys answered 23/10, 2020 at 13:47 Comment(0)
S
23

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.

Strophanthin answered 5/11, 2020 at 12:58 Comment(2)
What if in my xCode settings I have a blank for Objective-C Bridging Header?Impedimenta
add #import <React/RCTBridgeModule.h> #import <React/RCTViewManager.h>Hanford
U
0

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

Unscrew answered 14/3, 2023 at 17:53 Comment(0)
B
0

Xcode settings

Also, you can copy settings from General -> Objective-C Bridging Header -> Debug to Release -> Any Architecture | Any SDK if it is missing.

Brockwell answered 3/9 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.