dwghww
Last Updated: February 25, 2016
·
4.814K
· webdevotion

Open the Xcworkspace file in the current directory

Goal

I often navigate my folders using the command line.

When I want to open a Xcode Workspace I type the following command:

workspace  

The script ( aka 1 line of code )

Put this text in a new file workspace in your ~/bin folder.

It's possible you have to create that folder.

#!/bin/bash
open -a "/Applications/Xcode.app" *.xcworkspace

Then run source ~/bin/workspace to start using the script immediately.

If you want to load the script every time your boot up your computer

add this line to your ~/.bash_profile:

PATH=$PATH:/Users/`whoami`/bin

This line will add your ~/bin folder to your $PATH
so it's always accessible from the command line.

Usage

Whenever you're in a folder containing a *.xcworkspace file

you just type workspace to open the current Workspace in Xcode.

workspace  

Remark

When you have Developer Previews installed of Xcode,

make sure you have set the current stable version of Xcode

as the default application of *.xcworkspace.

Otherwise the latest ( and sometime not so greatest ) version of Xcode

will take over, which can be annoying when you are working on production apps.

The easiest way to do this is probably through Finder.

1 Response
Add your response

13977

I've got this working all the way down to the 'source ~/bin/workspace' command but have not gotten the 'workspace' command to work on it's own. (Command not found)

I did add 'PATH=$PATH:/Users/whoami/bin' to my ~/.bash_profile

Any idea where I could have gone wrong?

Thanks for writing this up

over 1 year ago ·