如何添加iOS键盘扩展到react native?

58wvjzkj  于 2023-05-23  发布在  iOS
关注(0)|答案(1)|浏览(130)

从默认的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

lstz6jyr

lstz6jyr1#

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

相关问题