Hi fellow software enthousiasts,
I am currently working on a React native project for which I need to add some logic which has been written in swift. I am able to trigge
I did eventually come up with a solution. It is not exactly like React native people intended it I believe, but it works. So i can continue and maybe someone else is set on the right track with my solution. Although, please post the way it is supposed to be.
So I decided to start with the Objective-C way first. So I created a .h file for my module.
MyLoginBridge.h
#import
@interface MyLoginBridge : NSObject
@end
Then alter the .m file
#import "MyLoginBridge.h"
#import "MyProject-Swift.h" // Include the swift header manually
@implementation MyLoginBridge
RCT_EXPORT_MODULE(MyCustomLoginJSName);
RCT_EXPORT_METHOD(loginWithEmail:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
// Manually init the module and call swift function
MyLoginModule* module = [[MyLoginModule alloc] init];
[module loginWithEmailWithResolver:resolve rejecter:reject];
}
@end
The swift file and the bridging header remained the same. This works.