在 Xcode 中调试静态库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25512585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:26:19  来源:igfitidea点击:

Debugging a static library in Xcode

iosobjective-cxcodedebuggingstatic-libraries

提问by AlbeegartDev

I am building a static library and am receiving no compiling errors, however, when I link it against a demo project(basic single view app). I cannot step into the methods called from the static library to debug it...

我正在构建一个静态库并且没有收到任何编译错误,但是,当我将它链接到一个演示项目(基本的单视图应用程序)时。我无法进入从静态库调用的方法来调试它...

I'm not receiving any runtime errors, but I think that is because it's not being executed due to the fact my NSLogs are not being shown, and it's not returning anything...

我没有收到任何运行时错误,但我认为这是因为它没有被执行,因为我的 NSLogs 没有被显示,而且它没有返回任何东西......

Basically, how do I debug a static library I created through the demo app I also created..

基本上,我如何调试我通过我也创建的演示应用程序创建的静态库。

What do I do? I need help!!

我该怎么办?我需要帮助!!

Thanks in advance...

提前致谢...

回答by Injectios

To use runtime debuggeryou should add your staticlibrary project as subprojectto your sample where you want to debug it.

要使用运行时,debugger您应该将您的static库项目添加subproject到您想要调试它的示例中。

Make sure that GENERATE_DEBUG_SYMBOLSis set to YES (debug mode) for your staticlib.

确保GENERATE_DEBUG_SYMBOLS为您的staticlib设置为 YES(调试模式)。

In case of using in project compiled staticlibrary (libYourLib.a) you won't be able step into methods but still should see NSLogcoming.

如果在项目编译static库 (libYourLib.a)中使用,您将无法进入方法,但仍然应该看到NSLog即将到来。

回答by Alberto Salas

If your static library is not a subproject or it is not in the same workspace, first make sure that GENERATE_DEBUG_SYMBOLSis set to YES (debug mode), as @Injectios says. Then go to Breakpoint Navigator, add a new "Symbolic Breakpoint" with the class/method you are interested in, and run your application.

如果您的静态库不是子项目或不在同一个工作区中,请首先确保将GENERATE_DEBUG_SYMBOLS其设置为 YES(调试模式),如@Injectios 所说。然后转到Breakpoint Navigator,使用您感兴趣的类/方法添加一个新的“符号断点”,然后运行您的应用程序。

回答by learn_develop

The way I generally do it in my pre-compiled static library is that I would add a breakpoint at viewDidloadand then when the breakpoint is hit and if we know which methods to add the breakpoint to, I would add a breakpoint like b <function_name>and then press continue, and when that function is hit during the execution, it would break and we can use regular lldb options to continue, step over and step into the code.

我通常在预编译的静态库中这样做的方式是,我会在断点处添加一个断点,viewDidload然后当断点被击中时,如果我们知道将断点添加到哪些方法,我会添加一个断点b <function_name>,然后按继续,当该函数在执行过程中被命中时,它会中断,我们可以使用常规的 lldb 选项来继续、单步执行和单步执行代码。