I would like to know how to do this from the CLI so that I can test out some codes without launching Xcode. I saw someone did this but I couldn't find a way to do this yet.
After installing the Xcode6 beta, do
$ sudo xcode-select -s /Applications/Xcode6-Beta.app/Contents/Developer/
$ xcrun swift
is a Swift REPL
EDITED:
For XCode 6, use:
xcrun swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
To extend on @vinicius answer, you can also use it without changing your default Xcode by using:
DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer/ xcrun swift
The easiest way to do that will be to edit your .bashrc and append:
alias swift='DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer/ xcrun swift'
At that point you'll be able to run it just by typing swift
If you use a csh variant you'll need:
env DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer/ xcrun swift
and create the alias with
alias swift 'env DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer/ xcrun swift'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With