I'm trying to call a Method from Objective-C that has been defined using a Macro which wraps a Swift function. I'm getting the compilation error No visible @interface for 'NearbyMessages' declares the selector '__rct_export__disconnect'
in Xcode when I try to call my Method though.
My Swift function looks like this:
// SomeInterface.swift
@objc
func disconnect() -> Void {
// (disconnect logic here)
}
The Objective-C code looks like this:
// SomeInterface.m
@interface RCT_EXTERN_REMAP_MODULE(SomeInterfaceNameJS, SomeInterfaceNamePrivate, NSObject)
RCT_EXTERN_METHOD(disconnect);
-(void) invalidate {
[self __rct_export__disconnect]; // No visible @interface for 'NearbyMessages' declares the selector '__rct_export__disconnect'
NSLog(@"GNM_BLE: invalidate!");
}
@end
The macro RCT_EXTERN_METHOD
(from React's RCTBridgeModule.h
) is defined as:
#define RCT_EXTERN_METHOD(method) \
_RCT_EXTERN_REMAP_METHOD(, method, NO)
#define _RCT_EXTERN_REMAP_METHOD(js_name, method, is_blocking_synchronous_method) \
+ (const RCTMethodInfo *)RCT_CONCAT(__rct_export__, RCT_CONCAT(js_name, RCT_CONCAT(__LINE__, __COUNTER__))) { \
static RCTMethodInfo config = {#js_name, #method, is_blocking_synchronous_method}; \
return &config; \
}
By reading this, upon compilation the Method should be called __rct_export__disconnect
, right?
So why is it not possible to use [self __rct_export__disconnect]
- How else can I call this method?