体系结构x86_64的未定义符号:"std :: terminate()",引用自

dej*_*eju 22 objective-c react-native

react-native run-ios在升级后的RN 运行到0.26.0-rc后运行时出错.

Undefined symbols for architecture x86_64:
      "std::terminate()", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "___cxa_begin_catch", referenced from:
      ___clang_call_terminate in libReact.a(RCTJSCExecutor.o)
  "___gxx_personality_v0", referenced from:
      -[RCTJavaScriptContext initWithJSContext:onThread:] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJavaScriptContext invalidate] in libReact.a(RCTJSCExecutor.o)
      _RCTNSErrorFromJSError in libReact.a(RCTJSCExecutor.o)
      +[RCTJSCExecutor runRunLoopThread] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor init] in libReact.a(RCTJSCExecutor.o)
      -[RCTJSCExecutor context] in libReact.a(RCTJSCExecutor.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

Jos*_*das 62

运行后解决了以下建议rnpm-plugin-upgrade@0.26:

[...]加-lc++Other Linker Flags你的Xcode项目构建设置.

正如评论中指出的那样更新目标构建设置(而不是项目).您可能还需要更新测试目标.

  • 刚救了我的一天.谢谢. (3认同)
  • 你必须将它添加到测试目标太(默认的),看https://github.com/facebook/react-native/issues/7566#issuecomment-242034598.我必须选择评论中显示的"测试"目标,但也必须将视图从"基本"切换到"全部",以便能够将其添加到"其他链接器标志" (2认同)

小智 8

当我将 Facebook SDK 添加到我的项目时,出现以下错误:

Showing Recent Messages
Undefined symbol: ___gxx_personality_v0
Undefined symbol: operator delete(void*)
Undefined symbol: std::__1::__next_prime(unsigned long)
Undefined symbol: vtable for std::length_error
Undefined symbol: ___cxa_rethrow
Undefined symbol: vtable for std::out_of_range
Undefined symbol: std::length_error::~length_error()
Undefined symbol: std::out_of_range::~out_of_range()
Undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)
Undefined symbol: std::__1::__shared_weak_count::~__shared_weak_count()
Undefined symbol: ___cxa_end_catch
Undefined symbol: ___cxa_allocate_exception
Undefined symbol: std::logic_error::logic_error(char const*)
Undefined symbol: typeinfo for std::exception
Undefined symbol: typeinfo for std::__1::__shared_weak_count
Undefined symbol: operator new(unsigned long)
Undefined symbol: ___cxa_begin_catch
Undefined symbol: vtable for __cxxabiv1::__si_class_type_info
Undefined symbol: std::__1::__vector_base_common<true>::__throw_length_error() const
Undefined symbol: std::__1::__shared_weak_count::__release_weak()
Undefined symbol: typeinfo for std::out_of_range
Undefined symbol: typeinfo for std::length_error
Undefined symbol: ___cxa_throw
Undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Undefined symbol: std::terminate()
Undefined symbol: std::__1::__basic_string_common<true>::__throw_length_error() const
Undefined symbol: ___cxa_free_exception
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题: Build Phases--> Link Binary With Libraries--> 添加“ libc++.tbd”。