【发布时间】:2021-12-06 07:44:33
【问题描述】:
我正在关注official doc 中针对本机模块 ios 发布的示例。我已经设置好一切,构建它并运行应用程序。
// CAL.h
#import <React/RCTBridgeModule.h>
@interface CAL : NSObject <RCTBridgeModule>
@end
// CAL.m
#import <React/RCTLog.h>
#import "CAL.h"
@implementation CAL
RCT_EXPORT_MODULE(CAL);
RCT_EXPORT_METHOD(createCalendarEvent:(NSString *)name location:(NSString *)location)
{
RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);
}
@end
但是当我从 react-native 检查 NativeModules 时,它会显示一个空对象 - {}。
我不确定我错过了什么。
【问题讨论】:
-
尝试直接检查
NativeModules.CAL -
是的,这就是我必须做的。谢谢
标签: ios objective-c react-native react-native-native-module native-module