-
-
Save lexrus/b2a86d4ae99e5509b3af to your computer and use it in GitHub Desktop.
把这个 swift 文件复制到 /usr/local/bin/ 下,chmod +x /usr/local/bin/auto-run.swift 。然后每次执行 auto-run.swift 都会检查是否需要重新编译,最后会执行编译后的 auto-run.swiftc。需要 Xcode 6.0+,亲测 bash 和 zsh 下可用,fish 下会报错。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/../usr/bin/true | |
source="$0" | |
compiled="$0"c | |
if [[ "$source" -nt "$compiled" ]]; then | |
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -g "$source" -o "$compiled" || exit | |
fi | |
"$compiled" | |
exit | |
*/ | |
println("👍") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment