You ever thought of writing all your codes in Swift? Now you can, with IBM’s Kitura, a Swift web framework and HTTP server that runs on OS X or Linux.
Open your terminal and download these requirements.
Downloading and installing git
Download OpenSSL and libssl-dev
Now, download swift 4.
After downloading and installing everything, untar the swift 4 file by running this cmd.
replace swift.tar.gz to the actual file you download.
After extracting, navigate inside the file and try running swift, use cd to change folder and ls to list what lies inside the directory you’re in.
exit from swift by typing :exit
once you are out of swift, in the terminal, type pwd and copy the location output.
Next is to export the path so we can run Swift wherever we are terminally.
Go to your home directory
Ater export the PATH
Note: if you are struggling on how to use vi? try gedit. i.e. gedit .profile
After opening .profile, navigate at bottom and add the export command you did, after #set PATH….
You should be able to run swift anywhere now, now we run kitura!
Create a folder myFirstProject or any name you prefer in terminal
Go inside myFirstProject folder
Inside the folder enter this command
It should look something like this
From the screenshot above, you see the package.swift file, which is the manifest file, all your dependencies goes in there, vi Package.swift or gedit Package.swift .
Inside Package.swift, enter the following.
Save and exit when you are done, next is to navigate to Sources/myFirstProject/ and vi main.swift
inside main.swift, your code should look like this
Go back to myFirstFolder and start your Kitura web server.
Open firefox and go to localhost:8080
That’s it, you can now right a web application using Apple’s Swift.
Next week I’ll post something about SwiftKueryMySQL.
Tags: Kitura, Swift 4, ubuntu, Web server
What is postfix? Postfix is a native mail transfer agent…
As we know that firebase keeps updating their API due…
vdmk file extension is used by HyperV qcow2 file extension…
Your email address will not be published.
Notify me of follow-up comments by email.
Notify me of new posts by email.