In terminal:
nano ~/.bash_profile
Place the following in the opened file:
# Open Xcode workspace from terminal.
alias workspace='open -a "/Applications/Xcode.app" *.xcworkspace'
alias project='open -a "/Applications/Xcode.app" *.xcodeproj'
Control X to close the file and Y to save it. Then press Enter.
Quit the Terminal and relaunch it for the changes to take effect.
- Inside a directory with a
.xcworkspacefile use the commandworkspaceto open Xcode. - Inside a directory with a
.xcodeprojfile use the commandprojectto open Xcode.