Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a library with Xcode

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.

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

Thanks a lot
–f

like image 842
flohei Avatar asked Oct 26 '10 16:10

flohei


People also ask

Can you debug in Xcode?

The Xcode/Android Studio debugger doesn't just allow you to Step Over into the next line. You can also go inside a function, Step Into, or advance to the next line outside the current method, Step Out. Or you can use the Xcode debugger commands directly or Android Studio LLDB.

How do you debug an Xcode project?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

How do you debug a Dylib?

First be sure that your dylib is build with the same architecture as your external program. Then Go to --> Product —>Scheme—>Edit scheme. Got to Tab Run(Debug) and check "Debug Executable" , then select into the dropdown button your external program as executable. Then check "Launch Automatically"

How do you add a breakpoint in Xcode?

Navigate to a line in your code where you want execution to pause, then click the gutter or line number in the source editor to set a breakpoint. Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it.


2 Answers

There have been a lot of discussions of how best to reuse code with static libraries. I've settled on the method described here by 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).

like image 74
Tim Isganitis Avatar answered Oct 31 '22 12:10

Tim Isganitis


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.

like image 39
Shawn Craver Avatar answered Oct 31 '22 11:10

Shawn Craver