I am working on an iOS bridge to integrate a .framework SDK into a React Native app.
The documentation for this SDK states I should pass a UIViewController as a delegate to the framework initialiser to which the SDK will notify all its outputs.
As React Native apps are built within a single UIViewController, I have passed that root UIViewController to the initialiser like so:
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;if (![CustomSDK isStarted]) { [CustomSDK startWithDelegate:rootViewController];}
Following the examples of iOS bridge in the React Native documentation, I have created a separate module to handle this where I've implemented the protocol methods.
// CustomSDKModule.h@interface CustomSDKModule : RCTEventEmitter <RCTBridgeModule, CustomSDKProtocol>@end
Using this root controller throws some warnings about incompatible types of UIViewControllers but the app builds and the SDK launches as expected.
The problems appear when the SDK tries to trigger the protocol methods. I have the protocol methods implemented in my CustomSDKModule.m file, the same file that has the method to initialise the SDK, but they are never triggered by the SDK. Instead, the app crashes with the following message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController CustomSDKMethodName:withCaptureType:]: unrecognized selector sent to instance 0x15dd2e8b0'
I'm wondering whether those methods should be declared within the implementation on the app's root UIViewController? e.g AppDelegate.m
Any tips on what I'm doing wrong or should be doing are appreciated