2 ways to compile swift code in windows with visual studio code
1. Use Windows Subsystem for Linux (WSL)
a. Enable Windows Subsystem for Linux (WSL)
b. Install Debian GNU/Linux from Microsoft Store
c. Start Debian the first time and go through the instructions
d. Get download Link for the latest swift version (Ubuntu 16.10) from https://swift.org/download/
e. Download the file with wget to /opt
sudo wget https://swift.org/builds/swift-4.1.3-release/ubuntu1610/swift-4.1.3-RELEASE/swift-4.1.3-RELEASE-ubuntu16.10.tar.gz --no-check-certificate
f. rename the file
sudo mv /opt/swift-4.1.3-RELEASE-ubuntu16.10.tar.gz /opt/swift.tar.gz
g. unpack the file
sudo tar -xf swift.tar.gz
h. rename the extracted folder
sudo mv swift-4.1.3-RELEASE-ubuntu16.10/ swift
i. Update repositories
sudo apt-get update
j. Install the packages clang libicu-dev libcurl3 libxml2
sudo apt-get install clang libicu-dev libcurl3 libxml2
k. Install the swift language extension for visual studio code
https://marketplace.visualstudio.com/items?itemName=Kasik96.swift
l. Install the CodeRunner extension for visual studio code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
m. Copy this powershell script to a random path (e.g. C:\scripts\Start-Swift)
param (
[string]$filename = ""
)
$filename = $filename.Replace("","/")
$filename = $filename.Replace(":","")
$filename = "/mnt/" + $filename
$command = "/opt/swift/usr/bin/swift '" + $filename +"'"
debian -c $command
n. Open User Settings with (CTRL & ,) in Visual Studio Code
o. Edit User Settings
"code-runner.executorMap": {
"swift":"powershell -executionPolicy ByPass -File C:\scripts\Start-Swift.ps1",
}
p. Create new file in visual studio code (with .swift suffix)
q. Code something in swift
r. Press CTRL ALT N to compile your swift code.
2. Use Swift for Windows
a. Install Swift for Windows from https://swiftforwindows.github.io/
b. Install the swift language extension for visual studio code
https://marketplace.visualstudio.com/items?itemName=Kasik96.swift
c. Install the CodeRunner extension for visual studio code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
d. n. Open User Settings with (CTRL + ,) in Visual Studio Code
e. Edit User Settings
"code-runner.executorMap": {
"swift": "C:\swift\setPath.bat && cd $dir && swiftc -swift-version 4 $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe",
},
f. Create new file in visual studio code (with .swift suffix)
g. Code something in swift
h. Press CTRL ALT N to compile your swift code.
Congratulations @lage2104! You received a personal award!
Click here to view your Board
Congratulations @lage2104! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!