18
votes

I managed to get my C++ project running in Xcode using cmake -G Xcode. Now I would like to debug it, because of the nice gdb fronted it provides.

However I need to change the working directory where gdb is executed otherwise it wont work. (It needs to read some data from files relative to the path of the working directory) What I can do is after gdb has stopped typing cd working_dir and then run it manually typing r. This works, but Xcode will complain constantly and is also not an elegant solution.

So somewhere in the build settings I should be able to set the working directory..but where?!

4
Nils: Please make the answer by gibertoni the accepted one. I spent some unnecessary minutes until I noticed that Paul's answer applies to a long-outdated version of Xcode. - fieres

4 Answers

45
votes

Just updating this solution to XCode 4.x

You go on Product -> Scheme -> Edit Scheme

On the tab Options you choose your working directory.

13
votes

In Xcode 4 the working directory settings is under Scheme Settings.

4
votes

In Xcode 3.x do a "Get Info" on the executable and look at the first tab - there is a setting there for working directory.

2
votes

The default debug working directory is somewhere under ~/Library/Developer/Xcode/DerivedData/project-/Build/Products/Debug. You're better off using the full path.