Last Updated: February 25, 2016
·
749
· nc

Open Xcode workspace from zsh

Here's a simple zsh function that will open a Xcode project's workspace. It will gracefully fall back to the project if there is no workspace.

function xcopen {
    files=$(ls $1.xcworkspace/ 2> /dev/null | wc -l | tr -d ' ')

    if [ "$files" != "0" ]; then
        open $1.xcworkspace/
    else
        open $1.xcodeproj/
    fi 
}

Usage: Change the project folder and type:

xcopen <Project Name>