Starting with the default React Native project, I followed the guidelines for creating a Keyboard extension and the default Apple code works. But when I add #import <RCTRootView.h>
to my file and the following is the only code in the extension ViewController file:
- (void)loadView {
NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"ReactAGKeyboard"
initialProperties:nil
launchOptions:nil];
self.view = rootView;
}
The build will fail with error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RCTRootView", referenced from: objc-class-ref in KeyboardViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I added Other Linker Flags -ObjC
to the Extension Target Build Settings from this similar question Using React Native within an iOS share extension
My code is here: https://github.com/jeremyhicks/react-native-keyboard-extension
It looks like you aren't linking your extension to react-native. You need to add the .a files which are presently in the Linked Frameworks and Libraries
of your container app target (ReactAGKeyboard) to your extension target (AGKeyboard).