[SOLVED] Attaching the debugger to Cocos2dx library in Xcode

I’m probably just missing something really obvious, but how do you attach the debugger to the Cocos2dx library in Xcode so that I can debug it? ie step through, break point, check variables etc.

This works perfectly fine when I run in Visual Studio, but I can’t seem to get it running for Xcode.

This might just be a way the project has been setup (I don’t know if this is default or not, I didn’t set it up originally). The cocos2d library has been attached as a project inside the main one:

Any idea?

Just expand the project, find the source you want, click to set a breakpoint, and it will stop there!

(At least it does with my projects, and there’s nothing unusual about them)

I am guessing it might be set up to use a precompiled engine - others here including @slackmoehrle I think do that - so may be able to help if that is the case.

Setting a breakpoint in the cocos2dx source doesn’t work, it’s ignored. Also breakpointing into my source shows the cocos2dx library just greyed out in the callstack as shown below. I can’t step into any cocos2dx library functions either, it just steps over them.

Any thoughts?

I do the same as @Maxxx it doesn’t look like he is using the pre-built libraries because he has the xcodeproj in his project.

Puzzling! I wondered if the cocos2d stuff had been added as a pre-built library, but as slackmoehrie says that doesn’t look like it is the case as you have the cocos2d project in there.

I guess it could be that you are using libraries but still have the source included -

There’s a whole slew of info on using built libraries - maybe reading through some of that and comparing with your set up might give you a clue.

Also, you could try removing the cocos xcode proj from your solution - if it still builds then that would indicate to me that the project is using pre-built libraries …

It doesn’t seem like it’s a pre-built library, there’s no libcocos2d.a file (looks like its generated each time I build) and editing the cocos2dx source does work, the changes are reflected when I build.

CCLOG in the cocos2dx library doesn’t seem to output anything, so I thought it might be building the library specifically in release mode, but unless I’m looking in the wrong place (which is likely), it seems to look like it should be building a debug build.

look at my reply here for how to use the pre-builts for ios and osx apps: How to speed up cocos2d-x build with prebuilt lib

I’ve had a look at that thread and tried a bunch of different search path settings (as shown in the link above, I’ve also tried copying the cocos2dx test projects) but the result is the same, I still can’t debug into the cocos2dx library code.

Again, I’m pretty sure it’s not using a pre-built library, there doesn’t exist a libcocos2d.a file in the project, and if I edit the source in cocos2dx library, the changes are reflected when I run the app.

Strange indeed!
At about this point, if it were me, I’d create a new cocos project and copy the Classes and Resources folder across - might be faster than fixing the issue (and you can always then compare the two projects)

I figured it out!

So I didn’t know this but you have to use the same configuration name in your library project (cocos2dx) as your main project. For most projects your configurations are ‘Debug’ and ‘Release’.

However, if in your main project you defined other configurations, eg ‘Beta’, ‘Staging’ etc then you need to have the corresponding ones in the cocos2dx library project too, and those with the appropriate settings. eg, if you want to debug your ‘Beta’ build, you need to make a ‘Beta’ config in your cocos2dx library and copy the ‘Debug’ config when prompted.

The project I’m using is setup so that there was no ‘Debug’ and ‘Release’ configs, so I could never debug into the cocos2dx library.

A pretty not ideal way to set up a project, but also not great from Xcode for it to not realise this either.

Thanks for your help guys. Much appreciated.