如何添加iOS键盘扩展以反应原生?

时间:2016-03-06 07:31:51

标签: ios keyboard react-native ios-extensions

从默认的React Native项目开始,我遵循了创建键盘扩展的指导原则,并且默认的Apple代码可以使用。但是当我将#import <RCTRootView.h>添加到我的文件中时,以下是扩展ViewController文件中的唯一代码:

- (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;
}

构建将失败并显示错误:

 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)

我将Other Linker Flags -ObjC添加到此类似问题Using React Native within an iOS share extension

的扩展目标构建设置中

我的代码在这里: https://github.com/jeremyhicks/react-native-keyboard-extension

1 个答案:

答案 0 :(得分:0)

看起来您没有将您的扩展程序链接到react-native。您需要将目前位于容器应用程序目标(ReactAGKeyboard)的Linked Frameworks and Libraries的.a文件添加到扩展目标(AGKeyboard)。