React Native bridging to swift native class not working

Viewed 185

We upgraded React Native from "^0.62.2" to "0.66.0". Before the Bridges worked fine. After using the latest version, i can't get even the basic tutorial running.

CalendarManager.swift


@objc(CalendarManager)
class CalendarManager: NSObject {
    
    @objc static func requiresMainQueueSetup() -> Bool { return true }
    
    @objc(addEvent:location:date:)
    func addEvent(_ name: String, location: String, date: NSNumber) -> Void {   // Date is ready to use!
        print("")
    }
    
    @objc
    func constantsToExport() -> [String: Any]! {
        return ["someKey": "someValue"]
    }
}

CalendarManager.m


@interface RCT_EXTERN_MODULE(CalendarManager, NSObject)

RCT_EXTERN_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(nonnull NSNumber *)date)

@end

And in React Native CalendardModule.ts


const { CalendarModule } = NativeModules;

type CalendarManager = {
  createCalendarEvent(name: string, location: string): void;
};

export default CalendarModule as CalendarManager;

So when i call


//some callback function
 const onClickListenerHandler = () => {
    console.log("Test");

    CalendarModule.createCalendarEvent("Test", "Test");
  };

I can see the "Test" log entry but nothing more. When debugging into the native code, the debugger won't hit the breakpoint in the swift class.

If i create an init method in CalendarManager.swift, it won't even get called.

What am i doing wrong?

0 Answers
Related