我正在尝试实现本机UI组件https://facebook.github.io/react-native/docs/native-components-ios.html,并且当我尝试在Xcode中创建以下文件时
// RCTMapManager.m
#import <MapKit/MapKit.h>
#import "RCTViewManager.h"
@interface RCTMapManager : RCTViewManager
@end
@implementation RCTMapManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[MKMapView alloc] init];
}
@end
我收到以下错误
RCTMapManager.m:3:9:找不到'RCTViewManager.h'文件
然后,我尝试将以下路径添加到标题搜索路径
$(SRCROOT)/../ node_modules / react-native / React / **
先前的编译错误已消失,但是在运行项目时出现以下错误
体系结构x86_64 clang的2个重复符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
任何想法 ??
我找到了解决我问题的方法。
基本上有两个问题。首先,导入应从“ React / RCTViewManager.h”而不是“ RCTViewManager”进行。
其次,该类不应命名为“ RCTMapManager”,因为该类已存在。应该将其命名为其他名称(例如“ RNTMapManager”)。
可以在以下github问题https://github.com/facebook/react-native/issues/12404上找到详细信息,并且此请求请求已修复文档https://github.com/facebook/react-native/pull/ 12523
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句