tags:

views:

676

answers:

4

Hi,

i have a XCode project (my main xcode project which has its executable). It has dependencies on a few other projects (under the Project tab in Detail View, there are a few other xcode project that it depends on).

My question is how can I setup breakpoint in the code of the dependent project?

I tried this, but this does not work 1. open my main xcode project 2. double click one of the dependent xcode project 3. in the source directory, find the file I want to break and add a breakpoint (by click at the side of the border of the editor, a blue 'bookmark thing' shows up) 4. Go back to 'Build and Go', my application does run but it never breaks at the break point I set in #3.

Can someone please help me? I have spent days on this, I can't figure it why.

Thank you.

A: 

a few things here...(some obvious some not)

1) be sure that the dependant project is compiled with debug symbols (i'm assuming its a library)

2) be sure that your active executable is linking against the debug version of your dependent library

3) set a breakpoint in your main project just before calling into the entry point of your lib, and set a bp on the entry-point of the lib... (in addition to the real breakpoint you are looking to hit...)

I have found that the best way to debug a library is to open the lib project and set the active executable to be the main project, and then just hit "build and debug" directly from the library project.

I hope this helps, good luck, and have fun!

kent
A: 

I've had similar problems with Xcode. The solution for me is to make sure that there is also a breakpoint in the main project that gets hit (as Kent mentions in his third point). I don't understand why this works though.

You should also only set breakpoints in a project when you've got it open. If you don't, they can start misbehaving: still stopping the flow of execution after you've disabled or deleted them, or not working when you think they're enabled.

Charles Anderson
A: 

Make sure you select 'Build and Debug' (for step #4). 'Go' sometimes means 'Run' (breakpoints disabled) and sometimes means 'Debug' (breakpoints enabled).

Also, make sure that you leave the dependent project open while you debug the main project.

Jon-Eric
A: 

I'll echo Jon-Eric here and also add that if you habitually run your project with Cmd+Enter, you should consider switching to Cmd+Y to enable gdb each time.

featherless