ADC Home > Reference Library > Technical Q&As > Tools > Xcode >

Debugging arbitrary applications with Xcode


Q: How do you debug an application with Xcode from a project other than the one that built it?

A: It is possible to debug an application using Xcode, even if you don't have the project that was used to build that application. This allows you to take advantage of Xcode's graphical debugging capabilities. And a similar approach works in Project Builder. Here's how:

  1. In Xcode, choose "New Project..." from the File menu, select "Empty Project" to create a new empty project, and click "Next".
  2. In the assistant dialog that appears, choose a project name and project directory where the project should be stored on disk. Then click "Finish".
  3. From the Project menu, choose "New Custom Executable".
  4. In the assistant dialog that appears, enter a name for the application you plan to debug, choose the path to the application by pressing the "Choose..." button, and then click "Finish".
  5. You are now ready to debug the application. Although the debug button will always be dimmed out in the toolbar, you can choose the "Debug Executable" menu item from the Debug menu to debug your application.



Note:
If you have the source code to the application available in a folder other than the location where it originally resided when building the application, you may want to make that available to the debugger so you can trace breakpoints into your code. There are two ways to do this.

In the Groups and Files list of the project window, select "Executables" (or go to the Targets tab in Project Builder) and double-click on your executable in the "Executables" list. This brings up the Executables editor for that executable. Add the path to the source code under "Source Directories". This will make your source code visible while debugging, but won't give you quick access to the source before the debugging session starts, to set breakpoints.

OR

You can add your source code to the project by dragging it into the project Groups and Files list, or by selecting the "Add Files..." menu item in the Project menu.




[Sep 15, 2003]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.