UPDATE: In Xcode 11, the shortcut mentioned in this tutorial (ctrl+alt+command+t) is used for “Editor Below” by default. You will need to replace it in order for this to work, or just choose a different shortcut.
Using third-party tools like CocoaPods for iOS development in Xcode, I often found myself in need of opening a Terminal window at the project location. Although I felt like a hacker for using Terminal at first (like the n00b I was), this becomes quite boring and tedious pretty soon.
My first solution was adding an “Open Terminal at this location” service to Finder, so I could right-click the project folder and open a Terminal window with that location preselected. This approach required you to jump out of Xcode, usually by clicking “Reveal in Finder” on your project file, in order to do this menial task.
So I scoured the web, and quickly put together a solution from a few different sources which allows me to open a Terminal window using a keyboard shortcut directly from Xcode.
TL;DR Here’s what you need to do:
1. Create a new text file with your favourite text editor and put this inside:
open -a Terminal "$SRCROOT"
2. Save it with a .sh extension in some permanent location where you wouldn’t see it everyday so it annoys you, and you won’t delete it by mistake.
3. Navigate to the location of the script file you just created using Terminal and change its permissions using:
chmod +x <fileName>
where <fileName> should be replaced with the name of the .sh file you just created.
3. In Xcode, go to Preferences -> Behaviors and click the plus sign in the bottom to add a new behavior and name it something like “Open Terminal”
4. Tick only the last checkbox, where it says “Run”, and select the location of your .sh file.
5. Click the little ⌘ symbol to the right of your behavior name and select a new keyboard shortcut for your behavior. I recommend: ctrl+alt+command+t.
That’s it, you’re done!
raywenderlich.com — Xcode Tips and Tricks