A Better way to Access Swift From the Terminal
Join the DZone community and get the full member experience.
Join For FreeA Better Way to Access Swift From the Terminal
Introduction
In my original post, I described how to create an alias to run Swift from the terminal. The only problem was when the user closed the terminal window, they would have to run the 'alias' command again. In this short tutorial, we are going to setup a way that the alias "sticks" between terminal sessions.
Open the Terminal Window Again
Enter the follow command to open your .bash_profile in TextEdit:
touch ~/.bash_profile; open ~/.bash_profile
Enter the following command in TextEdit changing only the Xcode6-BetaXX number (for whichever version of the beta you are using):
alias swift="/Applications/Xcode6-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift"
Save the File by pressing CMD+S and quit TextEdit by pressing CMD-Q.
Return to the terminal window and type:
source ~/.bash_profile
This will load the bash file without having to reboot.
Now if you simply type swift then you can access the Swift REPL.
After a Reboot
Simply type swift from the terminal without having to set the alias again since it was loaded during startup in your .bash_profile.
Published at DZone with permission of Michael Crump. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Comparing Cloud Hosting vs. Self Hosting
-
Introduction To Git
-
Micro Frontends on Monorepo With Remote State Management
-
Integration Architecture Guiding Principles, A Reference
Comments