Getting Started

Develop your first Kitura web application.

Install prerequisites.

Install Homebrew tap.

Installing Kitura’s Homebrew tap will allow brew to access Kitura’s package repository.

brew tap ibm-swift/kitura

Install Kitura’s command-line interface.

brew install kitura

Create a directory for your Kitura project.

mkdir HelloKitura
cd HelloKitura

Using the Kitura command-line interface, generate a basic starter project.

kitura init

info You can learn more about the generated project structure.

Open the generated HelloKitura.xcodeproj project in Xcode.

open HelloKitura.xcodeproj

Edit Sources/Application/Application.swift and add the following code inside the postInit() function.

// Handle HTTP GET requests to /
router.get("/") {
    request, response, next in
    response.send("Hello, World!")
    next()
}

Edit the Xcode build scheme so it specifies HelloKitura as the Executable (by default it will be set to HelloKitura-Package when you open Xcode).

EditXcodeBuildSchema

Click the play button (⌘-R) to build and run your new web application.

Open your web browser at http://localhost:8080.

You should see the following page in your browser:

"Hello, World!"

Congratulations! You have just created your first server-side Swift application using Kitura.


Next


If you like what you’ve seen of Kitura so far, star the repository by clicking the button below.

Join in the conversation on Slack.

Slack