This guide provides basic instructions on creating a quick Alloy project. Alloy is an MVC framework to help you quickly build Titanium applications.
line interface installation
To create and manage Alloy applications, you need the Alloy command-line interface. If you already installed Appcelerator Studio or the Appcelerator CLI, the Alloy CLI will be automatically installed for you. If you need to install Appcelerator Studio, see the Titanium SDK Quick Start or if you need to manually install the Appcelerator CLI:
- Download and install Node.js from http://nodejs.org/#download, which includes the npm package manager needed to install the Appcelerator CLI.
From a terminal, run the following command to install the CLI:
[sudo] npm install appcelerator -g
After installation, run the setup command to install required components:
After the CLI downloads and installs the required components, you will be prompted to login and authorize your computer. The CLI will ask to send an authorization token to your e-mail account or as a text to your mobile phone. Enter the authorization token once you receive it to complete the registration process.
To create a new Alloy project, start Appcelerator Studio, then
A new skeleton Alloy project will be generated in the directory named after the application name.
The following example converts the
image_view_file.js file from the Titanium KitchenSink sample application to an Alloy project.
The Alloy CLI converts the view, style and controller in to a Titanium project, which can be built and ran by Studio or the Appcelerator CLI.
In the Project Explorer view, select your project, then from the global tool bar, select Run from the Launch Mode drop-down and select the device to launch the application on in the Target drop-down. Alloy will generate the Titanium files from the Alloy project files, which will then be compiled by Studio and launched on the device simulator.
Using the CLI
From a console window, go to the root directory of the project, then
Refer to the Appcelerator Command-Line Interface Reference for more information about using the
appc run command.
For more examples of Alloy, see see Alloy Samples.
Review Alloy Concepts to learn more about Alloy and how to structure your project. From there, visit the links on Alloy Views, Alloy Controllers, and Alloy Models to learn how to write views, controllers and models, respectively.