[Tips] How to setup swift on windows 10

0
28
Good new for window user. Swift have supported on windows 10 right now, This article will be share for you how to setup swift and use it on window 10 🙂

Setup swift on window 10

1. Enable Ubuntu Bash Shell on windows 10

Step 1: Enable developer mode

– Settings -> Update and Security -> For developers, enable it  by check into below radio button

Setup swift on window 10
Step 2: Enable Subsystem window for Linux environment

Control Panel -> Programs and Features -> Turn Windows Features On or Off  -> Check into Windows Subsystem for Linux (Beta)

Setup swift on window 10
Step 3 – Download Bash On Ubuntu for Windows 

Click to start button -> type “bash”

Setup swift on window 10
– “Bash” command will auto download Bash on Ubuntu into Windows. After this we go to create username and password to use in Bash environment later

Setup swift on window 10
Setup swift on window 10

After download Bash succeed, you can see same here.

2. Install required dependencies

– Setup clang libicu-dev “apt-get install clang libicu-dev”
– Use “sudo-su”  command to change root permission to install the lib

Setup swift on window 10
Setup swift on window 10

3. Download the latest swift binary release

  • Download latest version of Swift binary for Ubuntu 14.04 from here
  • Create Swift folder in C driver
  • Copy Swift binary into Swift folder
  • Type commandcd /mnt/c/Swift
Setup swift on window 10

4. Setup Swift

– Type “tar -zxvf swift-X.X.X-RELEASE-ubuntuX.X.tar.gz” command to extract folder and go to install Swift
Setup swift on window 10

– Install succeed!

Setup swift on window 10

5. Change directory to swift compiler bin

– cd “swift-X.X.X-RELEASE-ubuntuX.X/usr/bin”.
In this bin folder is the place create swift code file and compiler
Setup swift on window 10

6. Write “Hello World” Swift On Windows 10

Setup swift on window 10
Setup swift on window 10 hello world
Setup swift on window 10

7. Compile và Run

– Compile helloworld.swift file by use command “./swiftc helloworld.swift”
– Run “./helloworld”
Setup swift on window 10