问题描述
我使用 react-native init
创建了一个 react-native 项目然后,我使用 File -> new -> target -> Action Extension 向该项目添加一个动作扩展,名称为Stash"我尝试添加一个从 UIView 继承并包含 RCTRootView 的 StashView,如 与现有应用说明集成:
I created a react-native project using react-native init
I then add an action extension to that project using File -> new -> target -> Action Extension, with the name "Stash"I try adding a StashView that inherits from UIView, and contains an RCTRootView, as instructed in the Integration with Existing App instructions:
Stash/StashView.h:
Stash/StashView.h:
#import <UIKit/UIKit.h>
@interface StashView : UIView
@end
Stash/StashView.m:
Stash/StashView.m:
#import "StashView.h"
#import "RCTRootView.h"
@implementation StashView
- (void)awakeFromNib {
NSString *urlString = @"http://localhost:8081/stash.ios.bundle";
NSURL *jsCodeLocation = [NSURL URLWithString:urlString];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName: @"Stash"
launchOptions:nil];
[self addSubview:rootView];
rootView.frame = self.bounds;
}
@end
编译时报错:
体系结构 x86_64 的未定义符号:
_OBJC_CLASS_$_RCTRootView",引用自:StashView.o ld 中的 objc-class-ref:找不到体系结构 x86_64 clang 的符号:错误:链接器命令失败,退出代码1(使用 -v 查看调用)
完整的堆栈跟踪:
LD/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Products/Debug-iphonesimulator/Stash.appex/Stash普通 x86_64cd/Users/danoved/Source/myprojects/ToDoBox导出 IPHONEOS_DEPLOYMENT_TARGET=8.1导出路径="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-arch x86_64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk-L/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Products/Debug-iphonesimulator-F/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Products/Debug-iphonesimulator-filelist/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Intermediates/ToDoBox.build/Debug-iphonesimulator/Stash.build/Objects-normal/x86_64/Stash.LinkFileList-Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../../Frameworks -Xlinker -objc_abi_version -Xlinker 2 -OjbC/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.平台/开发者/SDKs/iPhoneSimulator8.1.sdk/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit -e _NSExtensionMain -fobjc-arc -fobjc-link-runtime -fapplication-extension -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.1 -Xlinker -dependency_info -Xlinker/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Intermediates/ToDoBox.build/Debug-iphonesimulator/Stash.build/Objects-normal/x86_64_Stash_dependency.dat-o/Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Products/Debug-iphonesimulator/Stash.appex/Stash
我做错了什么?构建设置中的某些内容?
What am I doing wrong? Something in the build settings?
推荐答案
想通了!
基于此处的答案
我必须在扩展的构建阶段打开链接二进制文件和库胡萝卜,并将所有反应库添加到其中:
I had to open the Link Binary with Libraries carrot in the Build Phases of the extension, and add all of the react libraries to it:
这篇关于架构 x86_64 的未定义符号:将扩展目标添加到本机项目后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!