使用 Xcode 调试库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4025732/
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-14 19:52:43  来源:igfitidea点击:

Debugging a library with Xcode

objective-ccocoa-touchxcodeframeworksshared-libraries

提问by flohei

I have a more general question on working with libraries on with Xcode when building iPhone apps. I've created a framework from a project I've been working on to use some parts of it in other apps. That works pretty good, so far. But I have no idea how to debug into the files included in the included framework.

在构建 iPhone 应用程序时,我有一个关于使用 Xcode 使用库的更普遍的问题。我从我一直致力于的项目中创建了一个框架,以便在其他应用程序中使用它的某些部分。到目前为止,效果很好。但我不知道如何调试包含在包含框架中的文件。

I hope to get some kind of 'best practice' on that.

我希望在这方面获得某种“最佳实践”。

Thanks a lot
–f

非常感谢
-f

回答by Tim Isganitis

There have been a lot of discussions of how best to reuse code with static libraries. I've settled on the method described hereby Clint Harris (which I think is what Shawn is suggesting as well). Creating a project dependency in this way automatically compiles the library for your project's target (simulator/device, debug/release) so you don't need four different copies of the compiled library sitting around. It also lets you step into the library source when debugging, as you want. Finally, updates to the library are included in any of the linked projects the next time those projects are compiled (so you don't have to recompile and redistribute the library binary to those projects yourself).

关于如何最好地重用静态库的代码已经有很多讨论。我已经确定了克林特哈里斯在这里描述的方法(我认为这也是肖恩建议的)。以这种方式创建项目依赖项会自动编译项目目标(模拟器/设备、调试/发布)的库,因此您不需要四个不同的已编译库副本。它还允许您在调试时根据需要进入库源代码。最后,下次编译这些项目时,库的更新将包含在任何链接的项目中(因此您不必自己重新编译和重新分发库二进制文件到这些项目)。

回答by Shawn Craver

Generally, I'll include the Xcode project for the library as an external project dependency of the main application's project. The advantage of project dependencies, is that you can add a build phase that builds a fresh copy of your library along with the main project, and of course it will let you set breakpoints in the library's code.

通常,我会将库的 Xcode 项目作为主应用程序项目的外部项目依赖项包含在内。项目依赖的优势在于,您可以添加一个构建阶段,与主项目一起构建库的新副本,当然它可以让您在库的代码中设置断点。