Pod安装期间Crashlytics错误"架构x86_64的未定义符号"

Shi*_*rma 11 xcode objective-c crashlytics

我正在使用Google Analytics,在运行pod后,会显示这些错误.我不明白为什么; project也有Crashlytics框架,但只有在添加Google Analytics后才会显示这些错误.

Undefined symbols for architecture x86_64:
  "std::get_terminate()", referenced from:
  _CLSExceptionCheckHandlers in Crashlytics(CLSException.o)
 "std::set_terminate(void (*)())", referenced from:
  _CLSExceptionInitialize in Crashlytics(CLSException.o)
  CLSTerminateHandler() in Crashlytics(CLSException.o)
"std::terminate()", referenced from:
  ___clang_call_terminate in Crashlytics(CLSException.o)
"typeinfo for char const*", referenced from:
  _CLSExceptionRaiseTestCppException in Crashlytics(CLSException.o)
  GCC_except_table1 in Crashlytics(CLSException.o)
"typeinfo for std::exception", referenced from:
  GCC_except_table1 in Crashlytics(CLSException.o)
  typeinfo for std::exception const* in Crashlytics(CLSException.o)
"vtable for __cxxabiv1::__class_type_info", referenced from:
  typeinfo for std::__1::__basic_string_common<true> in Crashlytics(CLSException.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__pointer_type_info", referenced from:
  typeinfo for std::exception const* in Crashlytics(CLSException.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__vmi_class_type_info", referenced from:
  typeinfo for std::__1::basic_string<char,  std::__1::char_traits<char>, std::__1::allocator<char> > in Crashlytics(CLSException.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"___cxa_allocate_exception", referenced from:
  _CLSExceptionRaiseTestCppException in Crashlytics(CLSException.o)
"___cxa_begin_catch", referenced from:
  CLSTerminateHandler() in Crashlytics(CLSException.o)
  ___clang_call_terminate in Crashlytics(CLSException.o)
"___cxa_current_exception_type", referenced from:
  CLSTerminateHandler() in Crashlytics(CLSException.o)
"___cxa_demangle", referenced from:
  +[CLSDemangleOperation demangleCppSymbol:] in Crashlytics(CLSDemangleOperation.o)
"___cxa_end_catch", referenced from:
  CLSTerminateHandler() in Crashlytics(CLSException.o)
"___cxa_rethrow", referenced from:
  CLSTerminateHandler() in Crashlytics(CLSException.o)
"___cxa_throw", referenced from:
  _CLSExceptionRaiseTestCppException in Crashlytics(CLSException.o)
"___gxx_personality_v0", referenced from:
  +[CLSDemangleOperation demangleBlockInvokeCppSymbol:] in Crashlytics(CLSDemangleOperation.o)
  +[CLSDemangleOperation demangleSwiftSymbol:] in Crashlytics(CLSDemangleOperation.o)
  -[CLSDemangleOperation main] in Crashlytics(CLSDemangleOperation.o)
  ___28-[CLSDemangleOperation main]_block_invoke in Crashlytics(CLSDemangleOperation.o)
  Dwarf Exception Unwind Info (__eh_frame) in Crashlytics(CLSDemangleOperation.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)

San*_*osh 35

对我来说,我有类似的问题,同时集成这个基于cordova的应用程序.

您看到的特定错误是因为没有链接libc ++.Crashlytics 3.0需要libc ++(不是libstdc ++),libz,SystemConfiguration.framework和Security.framework.应该通过SDK中的模块定义自动处理链接.如果您不使用模块,我们的引导安装应该插入所需的链接库.在这种情况下,这显然不起作用.

解决方案#1:开始使用模块.它们可以缩短构建时间,实现快速的互操作性,并且通常很有用.

解决方案#2:手动链接libc ++,libz,SystemConfiguration.framework和Security.framework. 解决方案#2 - 为我工作 这个答案是由mattie提供的Ref链接


刘俊利*_*刘俊利 1

在 Xcode 中,Santosh 的答案对我不起作用,但我只是将 .m 文件更改为 .mm 文件即可。

这是 .mm 和 .m 之间的区别

对于“普通”Objective-C,使用 .mm 而不是 .m 的主要缺点是 Objective-C++ 的编译时间明显更长。这是因为 C++ 编译器比 C 编译器花费更长的时间。使用 Xcode 3.2 及更高版本,Objective-C 代码可以使用 Clang 前端工具链来显着加快 Objective-C/C 编译时间。由于 Clang 尚不支持 Objective-C++/C++,这进一步拉大了两者之间编译时间的差距。

更好的策略是默认使用 .m。如果您稍后需要在开发中使用 Objective-C++,则将文件重命名为使用 .mm 扩展名并没有什么坏处。如果您在 XCode 中这样做,项目将自动更新以使用新命名的文件。

当然,一旦您尝试在运行时比较 Objective-C++ 与 Objective-C 的性能,所有标准警告都适用。由于 Objective-C++ 是 C++ 超集,而 Objective-C 是 C 超集,因此您正在处理两种不同的语言,每种语言在运行时都会进行性能权衡。考虑到您正在使用 Objective-X,您可能正在编写用户级应用程序(而不是系统级应用程序),并且 C 和 C++ 之间的性能差异可能完全取决于您编写高效算法的能力每种语言。如果您是 C++ 开发人员,您的代码可能会比 C 语言更好,反之亦然。因此,一如既往,使用适合工作的工具。

作为参考,您可能也对此答案感兴趣:C vs C++ (Objective-C vs Objective-C++) for iPhone

更新 2012 年 2 月 17 日 自 Xcode 4.0(带有 LLVM 3.0)起,Clang 已支持 Objective-C++。现在甚至 C++11 支持也相当强大。

Objective-C,.m / .mm 性能差异?