简体   繁体   English

Xcode 4中没有外部库的符号/来源

[英]No symbols/source for external library in Xcode 4

My application is not seeing source code for a library: 我的应用程序没有看到库的源代码:

  • If I "Jump to definition" on a library method, XCode takes me to the .h file but says there is no .cpp counterpart 如果我在库方法上“跳转到定义”,XCode会将我带到.h文件但是说没有.cpp对应文件
  • When debugging, I see no source code and most of the call-stack is missing for the library: 调试时,我看不到源代码,并且库中缺少大部分调用堆栈: 在此输入图像描述
  • I have made sure "Show disassembly when debugging" is UNchecked 我确保“在调试时显示反汇编”是UNchecked

I built the library as DEBUG and then packaged up the headers+.a file into a SDK dir. 我将库构建为DEBUG,然后将头文件+ .a文件打包到SDK目录中。 So I guess I need to either copy the debug files into that SDK dir as well, or tell my application where to look. 所以我想我也需要将调试文件复制到SDK目录中,或者告诉我的应用程序在哪里查看。 I'm not sure how to do either. 我不知道怎么做。

To clarify, my application project doesn't maintain a reference to the library project, only to the .a files and the header dirs. 为了澄清,我的应用程序项目没有维护对库项目的引用,只保留对.a文件和头文件的引用。 This is because the library project is created by CMake and I don't want to modify it. 这是因为库项目是由CMake创建的,我不想修改它。

First of all, you should check the .debug_str section of your static library to verify it contains the appropriate debug information. 首先,您应该检查静态库的.debug_str部分,以验证它是否包含相应的调试信息。

Try running this command on the terminal: 尝试在终端上运行此命令:

xcrun dwarfdump /path/to/library.a | grep "\.m"

You should see a bunch of your source (.m) file paths printed out. 您应该看到打印出一堆源(.m)文件路径。 Theoretically, this is where Xcode is going to look when you stop in the debugger, so make sure the paths here are correct. 从理论上讲,当你停在调试器中时,这就是Xcode的样子,所以要确保这里的路径是正确的。 If you don't see any paths, you will need to pass an appropriate debug flag (eg -g to the compiler when building your library. 如果没有看到任何路径,则需要在构建库时传递适当的调试标志(例如-g到编译器)。

If the paths are somehow incorrect, or you want to point them to some other location, you may be able to modify them as part of the build process in CMake, for example to make them relative to your project directory. 如果路径在某种程度上不正确,或者您想将它们指向其他位置,您可以在CMake中将它们作为构建过程的一部分进行修改,例如使它们相对于您的项目目录。 Try looking at " Make gcc put relative filenames in debug information ", which uses CMake to adjust these debug paths. 尝试查看“ 使gcc在调试信息中放置相对文件名 ”,它使用CMake调整这些调试路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM