Handle fallback if Xcode is not installed

If Xcode is not installed the
active_path = /Library/Developer/CommandLineTools
Thus if the active_path does not contain the word Xcode, we will fall
back to opening the project file with the Finder's recommended program
This commit is contained in:
John Regner 2016-02-22 09:36:54 -08:00
parent 447db36d6e
commit 0d60bdd1dd

View File

@ -15,8 +15,13 @@ function xc {
else
echo "Found ${xcode_proj[1]}"
active_path=$(xcode-select -p)
if [[ ${active_path} =~ "Xcode" ]]; then
active_path=${active_path%%/Contents/Developer*}
echo "Opening with ${active_path}"
open -a "${active_path}" "${xcode_proj[1]}"
else # No Xcode installed
open "${xcode_proj[1]}" # Fall back to using Finder suggested application
fi
fi
}