My first Swift “Hello World” application on Cloud Foundry

Share this post:

Apple recently announced the open sourcing of the Swift programming language. Swift was released just last year and has shown incredible growth. It is expected to supplant Objective-C which took the mobile world by storm when it was introduced.

I just gave a Microservices and Cloud Foundry talk at a Java meetup in Boston and claimed that there is a buildpack for whatever your favorite language. It’s a little bit of a stretch of course.

Given the recent buzz around Swift, I was asked if there is a buildpack for it. Although I had never tried Swift and did not know the answer I felt confident that there might be an existing buildpack already or there would be one soon.

Hello World with Swift and IBM Bluemix

As I started looking around, thanks to Dr. Nic of Stark and Wayne, and the Heroku buildpack for Swift built by Kyle Fuller, I was able to use the Swift Community Buildpack on IBM Bluemix — the power of open source and communities.

I followed the steps outlined in the original blog.

Clone the Swift Code

Use the git command to clone the Swift code:

git clone
cd Curassow-example-helloworld

Push the app to Bluemix

I made an insignificant change to Sources/main.swift to look something like below:

import Glibc
import Inquiline
import Curassow

serve { _ in
return Response(.Ok, contentType: "text/plain", body: "Hello Swift from Bluemix")

I used the community buildpack for Swift as indicated in the orignal blog to push the Swift app:

cf push swift-helloworld -b --random-route

Notice that the dependencies for running the Swift language code was automagically downloaded as seen in the output below:

Creating app swift-helloworld in org / space dev as

Creating route

Binding to swift-helloworld...

Uploading swift-helloworld...
Uploading app files from: /Users/raghavansrinivas/work/src/Curassow-example-helloworld
Uploading 2.3K, 6 files
Done uploading

Starting app swift-helloworld in org / space dev as
-----> Downloaded app package (4.0K)
Cloning into '/tmp/buildpacks/swift-buildpack'...
-----> Buildpack version 1.0.0
-----> Uploading droplet (92M)

0 of 1 instances running, 1 starting
1 of 1 instances running

App started

App swift-helloworld was started using this command `HelloWorld --workers 5 --bind$PORT`

Showing health and status for app swift-helloworld in org / space dev as

requested state: started
instances: 1/1
usage: 1G x 1 instances
last uploaded: Thu Dec 10 13:52:00 UTC 2015
stack: cflinuxfs2

state since cpu memory disk details
#0 running 2015-12-10 08:54:53 AM 0.0% 111.1M of 1G 293.2M of 1G

Run the app

You can use curl or invoke the app from the browser and you’ll see the unflattering output of Hello Swift from Bluemix.


Thanks to the Cloud Foundry ecosystem, finding a buildpack and running an app built on a new language took just a few minutes.

I look forward to learning Swift using IBM Bluemix now that I have the Development cycle in place.

All that you need to do is register for a Bluemix account or any other Cloud Foundry account and follow this example or download the Swift bits from There is more information including getting started material at Swift @ IBM.

More stories
May 1, 2019

Two Tutorials: Plan, Create, and Update Deployment Environments with Terraform

Multiple environments are pretty common in a project when building a solution. They support the different phases of the development cycle and the slight differences between the environments, like capacity, networking, credentials, and log verbosity. These two tutorials will show you how to manage the environments with Terraform.

Continue reading

April 29, 2019

Transforming Customer Experiences with AI Services (Part 1)

This is an experience from a recent customer engagement on transcribing customer conversations using IBM Watson AI services.

Continue reading

April 26, 2019

Analyze Logs and Monitor the Health of a Kubernetes Application with LogDNA and Sysdig

This post is an excerpt from a tutorial that shows how the IBM Log Analysis with LogDNA service can be used to configure and access logs of a Kubernetes application that is deployed on IBM Cloud.

Continue reading