Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: Error trying to get in touch with native module in the tutorial

Having issue with defining a native module from the tutorial in https://facebook.github.io/react-native/docs/native-modules-ios.html.

#import "CalendarManager.h"
#import <React/RCTLog.h>

@implementation CalendarManager

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(addEvent: (NSString *)name location: (NSString *)location)
{

}
@end

It give me the compile error in RCT_EXPORT_METHOD saying

"Expected ')'"

. and

'Type specifier missing, defaults to int' (later also appeared under RCT_EXPORT_MODULE)

like image 393
LittleFunny Avatar asked Jun 07 '18 23:06

LittleFunny


1 Answers

You need to insert #import <React/RCTBridgeModule.h> in CalendarManager.h either.

Like this

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

NS_ASSUME_NONNULL_BEGIN

@interface CalendarManager : NSObject<RCTBridgeModule>

@end

NS_ASSUME_NONNULL_END
like image 65
jinyang li Avatar answered Oct 31 '22 12:10

jinyang li