A Step-by-Step Guide to Getting Started
Author’s note: Although this blog is still useful, some of the content is out of date. Please check out the latest IBM Cloud Tools blogs here .
IBM Cloud Tools for Swift provides Mac users with a simple interface for deploying, managing and monitoring end-to-end Swift applications. The application integrates with tools designed by IBM Swift Engineers to easily get started writing Swift on the Server. Download the Beta version here then follow these 7 steps to start using it.
1. Discover IBM Cloud Tools for Swift
For those interested in creating Swift applications that span both client and server-side code, IBM has created and is updating a new exploratory app to help. IBM Cloud Tools for Swift (ICT) simplifies the management and deployment of server-side assets. ICT is a Mac Application that allows you to group client-side and server-side code written in Swift; deploy the server-side code to IBM Cloud; then monitor and manage your Projects from within the application. A Project in ICT is the marriage of related server-side and front-end/client-side code. It enables you to group both portions of your application to easily understand its components.
Within the application, you may notice that we use the term Cloud Runtime to designate server-side code. If you’re familiar with IBM Cloud nomenclature, Cloud Runtime generically refers to anything running on the IBM Cloud and a Cloud Runtime URL equates to a IBM Cloud Route.
We offer three options for creating Projects. If you are interested in learning more about how to develop Swift on the Server, we suggest you start with the BluePic sample app option. If you already have an understanding of Swift on the Server, you can create a Kitura Project. Kitura is an open sourced light-weight web framework for writing Swift on the server. You can learn more about IBM’s Swift-related initiatives by clicking here. If you are already creating client or server-side code in Swift on IBM Cloud, create an Empty Project where you can add existing assets.
To get started, download the Beta version of IBM Cloud Tools for Swift from our site by clicking here.
2. Get an IBM Cloud account
Before using the app, you will need to create and sign in to your IBM Cloud account. IBM Cloud provides a platform where you can host and integrate services. If you do not have an IBM ID, sign up for one and get started with your free 30-day trial. To create an account, click here. To learn more about what IBM Cloud offers, click here.
After creating an account, log in to IBM Cloud to set up your Org and Spaces. Orgs are for accounting purposes. If you belong to your business’s larger Org, your account will be paid for and managed by them. Spaces are areas for organizing shared IBM Cloud applications within your Org. You may want to set up a test space to easily distinguish between test Projects and Projects in production. You will also notice that IBM Cloud asks for your region. IBM Cloud servers sit across the globe to optimize your application. Early versions of ICT only support US South, so select US South as your region in order to use our application. Future versions will support other regions. To sum up, your Cloud Runtime will belong to a Space within your Org running on servers in the US South region.
3. Start a new Project
After signing in, click the “+” in the upper right hand corner of the application from the Projects view. This view is the default view when you load the application.
From there, you will have a choice between a few types of Projects. We will explore a few options in this article.
4. Create the Todo sample app
The Todo sample app is a great way to learn how to write Swift on the client and the server. You can find the latest guide by clicking here
5. Create a Kitura Project
Kitura enables development of back-end portions of applications for Swift. To learn more about Kitura, click here. This Project option will automatically clone the Kitura Starter Application to your computer, so you can immediately get started with writing server-side code. It is up to you if you’d like to optionally add a client. Choose Create Kitura Project from the Create New Project menu.
Enter a Project Name and click next.
Enter a Cloud Runtime Name. This will generate a Cloud Runtime URL on IBM Cloud. Select the space where you would like to deploy. Click Next.
Select the location where you’d like to store your project and click Choose.
The application will clone the Kitura Buildpack to your computer, deploy and compile the code to IBM Cloud, then run the Project on the server. This process will only take a few minutes to complete for you.
You will see the below screen showing your Cloud Runtime.
To start coding in Swift, click on the directory in light grey. This will open the Kitura Starter Application in Finder.
Drill into the Sources folder and open main.swift in your text editor (we’re using Xcode in this example). Edit the code within the Basic GET request section from “Hello from Kitura-Starter!” to “Success!”.
Return to the application and click deploy. Deploy is signified by the icon of a cloud with an arrow going into it.
Navigate to <YourCloudRuntimeName>.mybluemix.net/hello to see your changes.
Don’t be surprised if the deployment isn’t immediate. In the background, the application is installing and uploading items to make the process work. In some situations, the Beta version takes up to 10 minutes to deploy. We are actively working on reducing that time for our users.
6. Create an Empty Project
If you already have a Cloud Runtime written in Swift that you’d like to pair with client-side code in a new project, you should choose the Create Empty Project option from the Create New Project menu.
Choose a Project Name and click Create Empty Project.
From here, you can click the “+” button associated with Client Apps to add an existing file from your computer. Click the “+” button associated with Cloud Runtimes to add an existing Cloud Runtime from IBM Cloud or create a new Swift Runtime. If you create a new Swift Runtime, the application will clone the Kitura Starter Application to your computer.
Get Support and Provide Feedback
Now you can start creating your own Projects within IBM Cloud Tools for Swift. If you have questions along the way, reach out to us through dWAnswers by clicking here. If you have any feedback or issues, fill out our survey by clicking here. Stay up to date on other IBM initiatives around Swift by clicking here.
The IBM Cloud Tools for Swift beta team (Brian L. White Eagle, Nathan Hekman, Evan Compton, Rebecca Lemker, Aaron Kettl, Rolando Asmat, Adam Johns, Kyle Craig, Jessica Leavitt, Emma Tucker) looks forward to your feedback.