Just wanted to share one way to launch Xcode from Terminal.

I actually learned about this from a tweet, and recording it here will, of course, help me find it again in the future. There are plenty of tutorials online which focus on creating a bash script or a command alias of some kind, but as it turns out, Xcode already comes with this functionality built-in!

Meet the xed tool or the “Xcode text editor invocation tool”.

How to use it?

For example, imagine you are at the root of a folder containing a Swift Package. To launch Xcode by opening the Swift Package for editing:

$ xed .

Launch Xcode in the current folder from Terminal

You are probably wondering why not just use the open command and while that’s certainly an option, xed has the advantage of being part of the currently active Xcode toolchain. This means that even if you have several different versions of Xcode currently installed on the system, xed will always open the active version.

For the complete list of available commands, you can explore the manual page of the tool (man xed). Here are the ones I find myself using most often:

The xed manual page.