Skip to content

Instantly share code, notes, and snippets.

@CraigSiemens
Created June 17, 2020 18:01
Show Gist options
  • Save CraigSiemens/f8c62f68090afdfcc96001b98fa9c308 to your computer and use it in GitHub Desktop.
Save CraigSiemens/f8c62f68090afdfcc96001b98fa9c308 to your computer and use it in GitHub Desktop.
Quickly the Xcode workspace, project, or package in the current directory, or specify files to open in Xcode.
function xc {
xcodePath=`xcode-select --print-path | grep ".*\.app" -o`
if (( $# == 0 ))
then
xcworkspace=`ls -1 | grep *.xcworkspace | wc -l`
xcproject=`ls -1 | grep *.xcodeproj | wc -l`
package=`ls -1 | grep Package.swift | wc -l`
if (( $xcworkspace > 0 ))
then
open *.xcworkspace -a "$xcodePath"
elif (( $xcproject > 0 ))
then
open *.xcodeproj -a "$xcodePath"
elif (( $package > 0 ))
then
open Package.swift -a "$xcodePath"
else
echo "No workspace or project files found,"
fi
else
open -a "$xcodePath" "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment