Skip to content

Instantly share code, notes, and snippets.

@kmplngj
Forked from monkeydom/swiftc.sh
Created June 11, 2014 20:23
Show Gist options
  • Save kmplngj/bf014ed054fce7b012ea to your computer and use it in GitHub Desktop.
Save kmplngj/bf014ed054fce7b012ea to your computer and use it in GitHub Desktop.
#!/bin/sh
SWIFT=$(/usr/bin/env xcrun -f swift)
SCRIPTPATH=$1
COMPILEDPATH="$SCRIPTPATH.o"
SDKPATH=$(/usr/bin/env xcrun --show-sdk-path --sdk macosx)
#compile if necessary
if [ $SCRIPTPATH -nt $COMPILEDPATH ]; then
$SWIFT -o "$COMPILEDPATH" -sdk "$SDKPATH" "$SCRIPTPATH"
if [ $? -ne 0 ]; then
exit $?
fi
fi
# ${@:n} passes on all arguments, sarting with the nth, "${@:n}" makes it work iwth escaped arguments as well (spaces, etc)
$COMPILEDPATH "${@:2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment