In my react native project, I try to expose a swift function to the javascript code. It works well in debug mode, but when trying to archiving I get a Use of undeclared type RCTEventEmitter
error on my swift file.
The RCTEventEmitter
is imported in my RNUtils.m
file, and in the bridging header.
So I guess somewhere in the archiving, something fail with the bridging header, but I have no idea where.If I ask for a non existing import, it will tell me that it can't compile the bridging header, so the file is taken into account during the build.
// Utils.m#import "React/RCTBridgeModule.h"#import "React/RCTConvert.h"#import "React/RCTEventEmitter.h"@interface RCT_EXTERN_REMAP_MODULE(RNUtils, RNUtils, RCTEventEmitter)@end
// Utils.swiftimport Foundation@objc(RNUtils)class RNUtils: RCTEventEmitter { // my native code emitting events}
// MyApp-Bridging-header.h#ifndef MyApp_Bridging_Header_h#define MyApp_Bridging_Header_h#import <React/RCTBridgeModule.h>#import <React/RCTEventEmitter.h>#endif
- react-native 0.61.5
- xcode 11.5
- Swift 5