Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined symbols for architecture x86_64: after adding an extension target to a react-native project

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:

#import <UIKit/UIKit.h>

@interface StashView : UIView

@end

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

When I compile, I get the error:

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RCTRootView", referenced from: objc-class-ref in StashView.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

The full stack trace:

Ld /Users/danoved/Library/Developer/Xcode/DerivedData/ToDoBox-gmtanlmumdrkqactpypioaempcuc/Build/Products/Debug-iphonesimulator/Stash.appex/Stash normal x86_64 cd /Users/danoved/Source/myprojects/ToDoBox export IPHONEOS_DEPLOYMENT_TARGET=8.1 export PATH="/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.platform/Developer/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_info.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?

like image 863
Oved D Avatar asked May 08 '15 21:05

Oved D


1 Answers

Figured it out!

Based on the answer here

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:

enter image description here

like image 105
Oved D Avatar answered Oct 09 '22 15:10

Oved D