How to use Swift for web development

Click for: original source

The web development world is vast, and it’s easy to feel lost in the constant stream of new technologies emerging every day. Most of these new technologies are built using JavaScript or TypeScript. However, in this article, author will introduce you to web development using native Swift, directly inside your browser. By Mikhail Isaev.

For Swift to work natively on the web page it needs to be compiled to WebAssembly byte-code first and then JavaScript could load that code onto the page. The whole process of compilation is a bit tricky since we need to use the special toolchain and build helper files, that’s why there are helper CLI-tools available: Carton and Webber.

Carton is made by the SwiftWasm community and can be used for Tokamak projects, which is a framework that gives you the ability to write websites using SwiftUI. Webber is made for SwifWeb projects. SwifWeb is different in that it wraps the entire HTML and CSS standards, as well as all of the web APIs.

The article then walks you through every step of building web application. The source code is also provided. Nice one!

[Read More]

Tags web-development app-development how-to swiftlang