Surviving Xcode

A collection of tips to help you (and me) get through the bugs, crashes, and weirdness until it’s possible to switch IDEs, or Apple starts QAing C++.

(This is all based on my experiences with Xcode 3.0 running on OS X 10.5, Intel MacBook Pro.)

crashes on opening a project

This usually happens after a previous crash or quitting while a debugged program is hung.  Try removing the projectname.pbxindex directory, probably under obj/projectname.build.  It was suggested on the Xcode forums somewhere that if something unexpected happens during indexing, the index files become corrupted and cause a crash..  Nice.

“Warning - No location found for somefile.cpp:someLineNumber”

Is gdb (Xcode) telling you that it can’t set a breakpoint, even though you have debugging symbols enabled?  One possible cause is a struct/class defined in function scope.  This is pure speculation on my part; I suggest it because I have moved such a definition to file scope and had this error go away.  Once.

I’ve also found that *not* running the program under the debugger initially (command-y) but rather just running (command-r) and then setting the breakpoint sometimes works.

crashes when using the diagramming tools with a C++ project

Don’t even think it.  This will not only crash, but crash hard.  In one case it deleted the diagramming file I was working on.  Clearly a cunning trap set by Apple for the unwary.

symbol has different visibility

Two settings usually get me here: “Inline Methods Hidden” and “Symbols Hidden by Default”. If different components (libraries) of your project are built with different settings for these two, then inline methods can end up with “different visibility” in each project. I think standard c++ would be to turn both of these off.

not of required architecture

Often accompanied by the linker saying that certain symbols can’t be found, except when they are.  Check that you aren’t building for two (or more) architectures when you really only care about one.  I usually set “Architectures” on the project to be only i386.