2

I'm trying to add a native module to a react native project. When the user clicks a button in react native, I want to open the first screen of this native project: https://github.com/AgoraIO/OpenVideoCall-iOS/tree/master/OpenVideoCall

I followed the instructions here https://facebook.github.io/react-native/docs/native-modules-ios to make a native module in Obj-C. I have a class MainViewController which extends UIController. How can I launch or navigate to MainViewController from the objective-C file. I have turned on packages/definesmodules in Xcode build settings, and I try importing "buildtarget-Swift.h" as described here Call Swift function from Objective C class. The import works but MainViewController cannot be found when I try using it.

Here is my code (my Xcode target name is "merge_test" and MainViewController is in merge_test/OpenVideoCall/MainViewController.swift) : `

  #import "Call.h"
   #import <UIKit/UIKit.h>
   #import "merge_test-Swift.h"

   @implementation Call

   RCT_EXPORT_MODULE();

   //exports a method to javascript
   RCT_EXPORT_METHOD(navigateToExample:(NSString *)name){
     MainViewController * vc = [[MainViewController alloc] init];
   }

   @end

`

I get the error 'Unknown receiver mainviewcontroller' but I'm pretty sure I'm doing more wrong than just that. How do I do this? It was incredibly simple for android, I feel there must be a simple way for ios.

Thanks!

Sean Lintern
  • 3,103
  • 22
  • 28
xcodesucks123
  • 424
  • 4
  • 8

0 Answers0