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

1

6

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)

Puckett answered 7/6, 2018 at 23:15 Comment(0)
W
1

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
Walke answered 16/7, 2019 at 2:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.