本文介绍了如何使用Xcode调试dylib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于图库的Xcode项目。
我可以使用调试配置构建它,我需要调试它。我该怎么做?



理想的方法是设置一个测试代码来在项目文件中构建一个执行,然后在源代码中设置一个断点在古代图书馆。



但是,似乎Xcode arith项目不允许添加另一个使用arith库的use_arith项目。



人们用什么方法来调试Xcode中的动态库?



ADDED



我googled并发现一些调试dll的方法。附加到运行的进程可以是调试动态库的一种方式。而且,对于iPhone / iPad编程动态库是不允许的,所以使用静态库。


  1. 附加到正在运行的流程 -


  2. 使用Xcode调试图书馆 -


  3. 简单的模块化代码共享在iPhone应用程序:静态库和跨项目引用 -



解决方案

我可以找到一种在Xcode中调试动态库的方法。 p>

构建




  1. 创建一个库,我会称之为这个arith库。调试构建,以使libarith.dylib。

  2. 使项目使用库,我会称之为usearith。

  3. 对于userarith,Project-> Add To Project,并添加arith库。

  4. 打开项目信息,然后打开Build选项卡。 li>
  5. 转到搜索路径/图书馆搜索路径,拖放arith库。您应该删除库名称,只需要指定路径。使用标题搜索路径指定标题目录。

  6. 转到链接,设置其他链接标记,添加-larith



运行



现在,您应该可以将执行二进制文件链接到库。
对于运行,您需要将动态库复制到执行二进制文件所在的目录。



调试



您需要设置两个arith / usearith的断点。
您可以在arith中运行调试器,并使用步骤来在一个arith项目中调试代码。


I have a Xcode project for library arith.I could build it with debug configuration, and I need to debug it. How can I do that?

The ideal method would be to set up a test code to build an execution in a project file, and then set a breakpoint in a source code in arith library.

However, it seems that Xcode arith project doesn't allow to add another use_arith project that uses the arith library.

What method people use to debug a dynamic library in Xcode?

ADDED

I googled and found some ways to debug dll. Attaching to a running process can be one way of debugging dynamic library. And, for iPhone/iPad programming dynamic library is not allowed, so static library is used.

  1. Attaching to a Running Process - http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Attaching-to-a-Running-Process.html

  2. Debugging a library with Xcode - Debugging a library with Xcode

  3. Easy, Modular Code Sharing Across iPhone Apps: Static Libraries and Cross-Project References - http://www.clintharris.net/2009/iphone-app-shared-libraries/

解决方案

I could find a way to debug dynamic library in Xcode.

Build

  1. Make a library, I'll call this arith library. Debug build to make libarith.dylib.
  2. Make a project to use the library, I'll call this usearith.
  3. For userarith, Project->Add To Project, and add the arith library.
  4. Open Project info, and open the Build tab.
  5. Go to Search Paths/Library Search Paths, drag and drop the arith library. You should remove the library name as you need only specify the path. Specify the header directory with 'Header Search Paths'.
  6. Go to Linking, set Other Linker Flags, add -larith

Running

Now, you should be able to link the execution binary to the library.For running, you need to copy the dynamic library to the directory where the execution binary is located.

Debugging

You need to set the breakpoints both arith/usearith.You can run debugger in arith and use the step into to debug the code in a arith project.

这篇关于如何使用Xcode调试dylib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 02:29