Automatically open terminal when debugging in Xcode?
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?
- Automating TestFlightApp with Xcode and Provisioning Portal
- Learning and Understanding the Xcode Build System
- iOS: Deploy and run app on device through command-line without jailbreaking
- Setting copyright statement on a per-project basis?
- Recorder Service Error: Left Mouse Down: Failed to find matching element - Xcode error
- Appium Instruments crashed on startup
3 Solutions Collect From Internet About “Automatically open terminal when debugging in Xcode?”
In Xcode, go to your Target, then right-click and choose:
Add -> New Build Phase -> New Run Script Build Phase
then 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.
For anyone who’s still looking,
It’s really easy.. say you want to click run and have the app run in the Terminal. Here’s what you do:
Go to Build Phases -> Editor -> Add Build Phase -> Add Run Script Build Phase -> Click the down arrow on Run Script -> Add the following:
open /Applications/Utilities/Terminal.app /Users/yourusername/restofpath
Notes: Spaces use ‘\ ‘ if needed. Include your app name in the path. Don’t use quotes.
Click Run, and there you go!
If you want the Terminal to clear, in your source code type ‘system(“clear”)’ near main(). It’s the only solution I have while debugging. Works great.
Check my answer here to see how to setup Xcode scheme to fully automate debugging with using Terminal. I described it for ncurses that requires real Terminal to work.
- Using blocks in Restkit (like ASIHttpRequest Blocks)
- cameraOverlayView to crop the result in UIImagePickerController
- iOS Facebook SDK 3.1 Retrieve friend birthday returning null
- Fetch Facebook Mutual friends between me and another User
- Preferred approach to check optionals in Swift
- Fetch Contacts in iOS 7
- How to remove whitespace in a string?
- Missing symbol names when profiling IPhone application with Instruments
- How to change PFUser password in Swift?
- Load image from url in iPhone, only if small
- UITextView keyboardDismissMode Bug
- How to close an application programmatically when the user taps on a button
- Strategy to perform many Geocode requests
- Is it possible to generate Enterprise/In house Provisioning Profile of a wildcard AppID?