When debugging an executable in Xcode, I very often have to open up a terminal window, navigate to the executable’s working directory and do some work there. Is there any way to have Xcode automatically open a terminal window at this location each time I debug my program?
Share
In Xcode, go to your Target, then right-click and choose:
Add -> New Build Phase -> New Run Script Build Phasethen add the following:
Now, every time you Build your app, Xcode will run this build script and launch Terminal. Note that you need to point to the correct location of the terminal application. Best way to do this is find the Terminal.app and drag and drop it onto the above screen after you type “open”.
Once you have Terminal open, you will need to make an AppleScript to send the commands to Terminal to open the specific directory. Use the ‘osascript’ command to
send an AppleEvent to Terminal.