This guide provides basic instructions on installing the Alloy command-line interface (CLI) and creating a quick Alloy project.
Command-Line Interface Installation
The Alloy To create and manage Alloy applications, you need the Alloy command-line interface and plugin should . If you already installed Appcelerator Studio or the Appcelerator CLI, the Alloy CLI will be automatically installed by the studio updater. See Titanium SDK Quick Start for instructions. If there were installation problems or if you wish to install the Alloy CLI independent of the Studio installation, refer to the manual installation instructions below.
The following steps install the latest released version of Alloy.
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 from http://nodejs.org/#download, which includes the npm package manager needed to install Alloythe Appcelerator CLI.
From aconsole window
terminal, run the following command to installAlloy
[sudo] npm install appcelerator -g
By default, these installation directions will install the latest Alloy release. To install a specific released version, use the same directions, except after 'alloy', add the at symbol ('@') with the version number. For instance, executing
sudo npm install -g email@example.com will install version 1.0.0.
Bleeding Edge Installation
To install the latest development version of Alloy, after installing Node.js , clone the Alloy GitHub repository and perform an
npm install from the Alloy project's root directory:
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.
Create a Project
To create a new Alloy project, start Titanium Appcelerator Studio, then
- From the menu, select File > New > Mobile App Project. The New Mobile App Project wizard appears.
- Select Alloy in the Available Templates box, choose a template, then click the Next button.
- Complete all of the fields, then click the Finish button.
A new skeleton Alloy project will be generated. If you are familiar with classic Titanium development, the
Resources folder is hidden from the App and Project Explorer. All work for an Alloy project is done in the
Using the CLI
To create a new Alloy project, use the Titanium Appcelerator CLI to create a new Titanium project, then use the Alloy CLI to generate the Alloy framework componentsAlloy project. Run the following command in a terminal:
titaniumappc createnew --name=appname --id=com.domain.appname --platforms=android,ipad,iphone,mobileweb cd appname alloy new t titanium
You will be prompted to enter an application name and application ID.
A new skeleton Alloy project will be generated in the
appname directorythe 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.
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.
For the Mobile Web platform, compile the application using the CLI, then run it with Studio. Run the following command from a console to compile the application:
Using the CLI
From a console window, go to the root directory of the project, then
titaniumappc buildrun [-p platform]
The Titanium Appcelerator CLI contains hooks to the Alloy CLI, so you do not need to run any Alloy commands.
Refer to the Titanium the Appcelerator Command-Line Interface Reference for for more information about using the
appc run command.
For the Mobile Web platform, run the application from Studio after compiling it.
For more examples of Alloy, see Alloy Samples.