Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Skip to end of metadata
Go to start of metadata

Introduction

Appcelerator provides a command-line interface to check and configure your environment setup, create and build applications, and much more.  This guide covers how to install the Appcelerator CLI and execute some common tasks.

Run appc --help to see all available target options or see the Appcelerator Command-Line Interface Reference.

Installation

To setup the Appcelerator CLI, install Node.js, install the appcelerator module using the NPM CLI, then run the appc setup command to download and setup the latest CLI package.

Install Node.js

The CLI requires Node.js 0.10.13 or later. If you don't have Node installed, install it from:

Before installing the CLI, you should decide where you want the Node Package Manager (npm) to install packages. By default npm installs into /usr/local on OS X, which requires that you run npm as root. This is not recommended. You can avoid having to run npm by doing one of the following:

  • Make the /usr/local directory writable by all:

    sudo chmod 777 /usr/local
  • Set npm to install to your home directory, or another directory of your choosing by setting the npm prefix. For example, you can add the following to your .bash_profile or other initialization file: 

    export NPM_CONFIG_PREFIX=$HOME 

    In this case, npm packages are installed to $HOME/lib/node_modules and launch scripts are installed in $HOME/bin$HOME/bin must be in your PATH.

For more information, see Installing Node.

Install the CLI

  1. Install the appc CLI. You many need to prepend the command with sudo.

  2. Setup the Appcelerator Platform environment.  This process will download the latest updates, setup the CLI and verify your development environment.

  3. After getting the latest updates, you are prompted for your Appcelerator Platform credentials.

  4. If you are a member or more than one organization, you will be prompted to select an organization.

  5. Next, you must authorize your computer.  Select either to send the authorization code to a phone number (using SMS/text messaging) or e-mail associated with your Appcelerator Platform account.

  6. Enter the code you received.
  7. Finally, the CLI will ask you about the projects you want to develop, and based on your answers, will check your environment to verify it is OK.

If you encounter an error installing appc, see Troubleshooting npm Problems.

Update the CLI

The CLI has two components: the NPM package and the Core package, which contains the other CLI components.

To update the NPM package, run the npm install appcelerator -g command.  Note that you may need to prefix the command with sudo on OS X systems.

To update the Core package, run the appc setup command to download and install the latest package.

Configure the CLI

Proxy Setup

If you are using the Appcelerator CLI from behind a proxy, you need to configure your proxy server settings using the appc config set command to set the proxyServer variable to your proxy server settings.

Note: We encourage you to use appc config set cafile as a security option over appc config set strictSSL false as the latter doesn’t do SSL key validation when making requests.

Set the Core Package Version

To use a specific version of the core package (which contains specific versions of the Alloy, Arrow and Titanium CLIs), run the appc use <version> command.  If you do not have the specified version installed, the CLI will download and install it for you.

To see a list of available versions, run the appc use command (without a version).

Build Cloud Applications

For more tasks, see Arrow Project.

Create an Arrow Project

To create a new Arrow project, run the appc new command.  The CLI will prompt you to fill in the necessary information to create a project, such as the name of the project.  To create a new project with all the information specified in the command, run:

Run an Arrow Project

To run an Arrow project locally, run the appc run command from the project directory.

Publish an Arrow Project to Arrow Cloud

To deploy your Arrow application to the Arrow Cloud, run the appc publish command from the project directory.

Generate Cloud Components

To generate components, such as Models, Connectors, or Block, for your Arrow projects, run the appc generate command.  When prompted for the type of component, select Arrow Component, then follow the subsequent directions.

The components generated by the command are modular components that need to be published using the appc publish command, then installed to your Arrow projects using the appc install command.

Build Mobile Applications

Once you have your development environment correctly configured, you can create and build mobile applications.

Create a Alloy Project

To create a new Alloy project, run the appc new command.  The CLI will prompt you to fill in the necessary information to create a project, such as which platforms the application runs on and the name of the project.  To create a new project with all the information specified in the command, run: 

Create a Titanium Project

To create a classic Titanium project, follow the same directions when creating an Alloy project, except add the --classic flag to generate a Titanium class project.

Build an Alloy or Titanium Project

To build an Alloy or Titanium project to test on a device, simulator or emulator, run the appc run command from the project directory.  The CLI will prompt you to fill in the necessary information to build the project, such as which platform you want to test the application on.  More detailed examples are listed below.

Once the application is installed and launched, use native tools to test, debug and profile your application.  See Debugging and Profiling.

Icon

SDK Version Setting Precedence

The CLI checks several settings to see which SDK version to use to build your application. The following is a list of locations in the order of precedence. If an SDK version is not defined in that location, the next location is checked.

  1. tiapp.xml file version specified with the sdk-version tag.
    To change this version, manually edit the tiapp.xml file with a text editor or use Studio.
  2. --sdk command-line option with the appc run command.
  3. app.sdk setting specified with the appc ti config command.
    To check the version, run appc ti config and to change the version, run appc ti config app.sdk <sdk_version>.
  4. SDK select version.
    To check or change this version, run appc ti sdk select.

Android Emulator

You need to create an Android emulator or setup Genymotion before running these commands.

To build for an emulator, run appc run -p android.  Because no other options were specified, the CLI launches your default Android emulator and installs the application on it.

To launch a specific Android or Genymotion emulator, add the -C <EMULATOR_NAME> option.  

To retrieve a list of Android or Genymotion emulators, run the ti info -p android command.

Android Device

To build for an Android device, connect your device to the computer with a USB cable, then run:

iOS Simulator

To build for an iOS simulator, run appc run -p ios.  Because no other options were specified, the CLI launches the application on the default iOS simulator.

To use a specific simulator, add the -C <DEVICE_UDID> option.

To retrieve the simulator's UDID, run the appc ti info -p ios command.

iOS Device

Before deploying to an iOS device for testing, you need to generate a development certificate and development provisioning profile.  See Deploying to iOS devices.

The CLI allows you to install your application either to iTunes or directly to the device connected to your computer with a USB cable.  If you select to install to iTunes, you need to sync your device to iTunes in order to install the application.

To build for an iOS device, run:

If you omit the -V and -P options, the CLI will prompt you with options.  You can also retrieve the information from Xcode's Devices window or with the appc ti info -p ios command.

Mobile Web

To build for Mobile Web, run appc run -p mobileweb.  The CLI creates an unminimized version of your mobile web application for you to debug.  Copy the files in the ./build/mobileweb to a web server to test the application.  

Windows Phone Emulator

Requires CLI and SDK 4.1.0.

To build for a Windows Phone emulator, you need to obtain your Windows publisher ID.  After you have created your Windows Dev Center account, log in to https://dev.windowsphone.com/en-us/Account/Summary to get your publish GUID. 

To build for a Windows Phone emulator, run:

If you omit any of the optional parameters, the CLI will prompt you with options.

Windows Phone Publisher GUID

Icon

Prior to Release 5.0.0, you need to pass the -G option with your Windows Phone Publisher GUID rather than using the -I option with your Windows Publisher ID.

 

Windows Phone Device

Requires CLI and SDK 4.1.0.

To build for a Windows Phone emulator, you need to obtain your Windows publisher ID.  After you have created your Windows Dev Center account, log in to https://dev.windowsphone.com/en-us/Account/Summary to get your publish GUID. 

To deploy to a Windows Phone device, connect the device to your computer with a USB cable, then run:

If you omit any of the optional parameters, the CLI will prompt you with options.

Windows Phone Publisher GUID

Icon

Prior to Release 5.0.0, you need to pass the -G option with your Windows Phone Publisher GUID rather than using the -I option with your Windows Publisher ID.

Windows Computer

Requires CLI and SDK 4.1.0.

To deploy the application to your local Windows machine, you will need a certificate.  If you do not have a certificate, the CLI will launch the certificate maker for your to create one.

To deploy to your local machine, run:

If you omit any of the optional parameters, the CLI will prompt you with options. Prior to Release 5.0.0, the -I option was not required.

Package an Application

To package a mobile application, run the appc run command from the project directory.

Google Play APK

Before packaging an APK file for distribution, you need to generate a keypair and certificate for your application.  See Distributing Android apps.

To package an APK for Google Play, run:

If you omit any of the optional parameters, you will be prompted by the CLI to enter these values.  If the password for the private key of the keystore is different from the password for the keystore, add the --key-password <KEYPASS> option with the password of your private key.

iOS Ad Hoc Distribution

Before packaging for the iOS ad hoc distribution, you need to generate a distribution certificate and distribution provisioning profile.  See Distributing iOS apps.

To package an IPA file for Ad Hoc distribution, run:

If you omit any of the optional parameters, the CLI will prompt you with options.

iTunes Store

Before packaging for the iTunes Store, you need to generate a distribution certificate and distribution provisioning profile, and have an iTunes Connect account.  See Distributing iOS apps.

Icon

If you are using Mac OS X 10.9 (Mavericks), make sure you grant CLI access to the computer as described in Installing the iOS SDK: Note for Mavericks.

To package an APP bundle for the iTunes store, run:

The CLI installs the package to Xcode's Organizer and launches Organizer for you to start the submission process.

If you omit any of the optional parameters, the CLI will prompt you with options.

Mobile Web

To create a minified version of your Mobile Web application, run the ti build -p mobileweb -D production command.  Deploy the files in the ./build/mobileweb to a web server.

Windows Phone Store

Requires CLI and SDK 4.1.0.

To package for the Windows Phone Store (ARM architecture), you need to obtain your Windows publisher ID.  After you have created your Windows Dev Center account, log in to https://dev.windowsphone.com/en-us/Account/Summary to get your publish GUID. 

To package an APPX file for the Windows Phone Store, run:

If you omit any of the optionals parameters, the CLI will prompt you with options.

Windows Phone Publisher GUID

Icon

Prior to Release 5.0.0, you need to pass the -G option with your Windows Phone Publisher GUID rather than using the -I option with your Windows Publisher ID.

Windows Store

Requires CLI and SDK 4.1.0.

To package for the Windows Store (x86 architecture), you will need a certificate.  If you do not have a certificate, the CLI will launch the certificate maker for your to create one.

To package an APPX file for the Windows Store, run:

If you omit any of the optional parameters, the CLI will prompt you with options. Prior to Release 5.0.0, the -I was not required.

Clean Your Build Folder

If you run into issues building your application, you may need to clean your build folder.  Run the appc ti clean command or to clean for a specific platform, add the -p <PLATFORM> option.