是否所有 react-native '.h' 模块都必须以 'React/' 开头?

Do all react-native '.h' modules have to be prepended with 'React/'?

设置:


我开始使用 RN v0.41.2 并发现 v0.40 introduced a namespace breaking change 声明所有 React 导入都应以 React/ 为前缀。

documentation 显示不同。

所以,这是我唯一要做的事情吗:

// RNLib.h

#import "RCTBridgeModule.h"

@interface RNLib : NSObject <RCTBridgeModule>

@end

// RNLib.h

#import <React/RCTBridgeModule.h>

@interface RNLib : NSObject <RCTBridgeModule>

@end

或者我是否也必须为我的进口货做这件事:

// RNLib.m

#import "RNLib.h"

@implementation RNLib

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(helloWorld:(NSString *)world)
{
  return [NSString stringWithFormat:@"hello %@", world];
}

@end

// RNLib.m

#import <React/RNLib.h>

@implementation RNLib

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(helloWorld:(NSString *)world)
{
  return [NSString stringWithFormat:@"hello %@", world];
}

@end

我目前无法创建一个库并且link它是正确的(我试过很多东西)。

// somthing.m
#import "something.h"

上面这行是指 something.h 文件,该文件存在于实现文件的同一目录中。

只有来自 React 的模块应该在前面加上 "React/RCTWhatever.h"

当您链接本机库时,这对 Xcode 的 Header 搜索路径有有效的更改。

谢谢