| copyright |
|
||
|---|---|---|---|
| lastupdated | 2017-06-12 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #tutorial}
The following end-to-end tutorial walks you through the steps to create a project from the Web Basic Starter. Steps include installing prerequisite tools and how to run the project code.
{: #dev_tools}
Ensure that you install the prerequisite developer tools {: new_window}.
{: #choose_how}
You can create a project by using either the web-based {{site.data.keyword.dev_console}} or through the command-driven {{site.data.keyword.dev_cli_notm}}. Once the project is created, you can then run the project.
{: #create-devex}
-
Create a project in the {{site.data.keyword.Bluemix}} {{site.data.keyword.dev_console}}:
-
From the Getting Started
page in the {{site.data.keyword.dev_console}}, click Create Project.
You can alternatively click Create Project from the Projects page.
-
Select Web App and click Next.
-
Select Basic Web and click Next.
-
Enter your project name. For this tutorial, use
WebBasicProject. -
Enter a unique hostname, such as your initials plus
-devhost. For example:
abc-devhost-
Select your language platform. For this tutorial, use
Swift. -
Click Create.
-
-
Optional: Add the Data capability:
- Click View for Data on the Project Overview page.
You can alternatively select Create or Add Existing on the Capabilities > Data page.
- Enter your service name and click Create.
-
Generate your project code:
-
Click Get the Code on the Project Overview page to select your language.
You can alternatively click on the Code page.
-
Click Generate Code.
-
When the project code is finished generating, click Download Code to download your project archive.
-
-
Begin working with your downloaded project:
-
Expand the archived file.
-
Navigate to the new project directory.
-
Use the {{site.data.keyword.dev_cli_notm}} to proceed.
-
-
Optional: Update your project to generate a new language.
{: #create-cli}
-
Ensure that you install the {{site.data.keyword.dev_cli_short}}.
-
In your Terminal prompt, navigate to a local directory of your choice and run the following command.
bx dev create{: codeblock}
-
Provide the following values when prompted:
- Select a pattern: 1 (for Web)
- Select a starter: 1 (for Basic Web)
- Select a language: 2 (for Swift)
- Enter a name for your project:
WebBasicProjectCLI - Enter a hostname for your project:
abc-devhost-
Enter a unique hostname, such as your initials plus
-devhost. For example:abc-devhost
-
-
When your
WebBasicProjectCLIproject is successfully saved, navigate to theWebBasicProjectCLIfolder. -
Add your own code, build, and run the project.
-
Build the project with the following command:
bx dev build{: codeblock}
-
Run the project with the following command:
bx dev run{: codeblock}
-
{: #run}
You can run the application locally on your host system if you install the necessary build tools, or by using the available container support in the {site.data.keyword.dev_cli_notm}}.
{: #dev notoc}
- Install the node dependencies:
npm install
{: codeblock}
- Bundle your frontend code into a module:
gulp
{: codeblock}
- To build the project in your current project directory, enter the following command:
bx dev build
{: codeblock}
- To run the project in your current project directory, enter the following command:
bx dev run
{: codeblock}
- Open your browser to
http://localhost:8080.
{: #Xcode}
-
Create an Xcode project.
Before you can develop in Xcode, you need to use the Swift package manager to build an Xcode project.
swift project generate-xcodeproj{: codeblock}
-
Change your active target to the executable:
Next, open your project in Xcode and make sure that your active target is the executable. You can hold down the option key and click the drop-down menu to select the desired active executable.
-
Press run.
-
Open your browser to
http://localhost:8080.