Setting up the Titanium CLI

Overview

This guide covers the setup of the Titanium CLI tool if you want to exclusively use command-line tools for development. If you are using Studio 3.x and later, the CLI is automatically installed if you chose to install additional Titanium updates. For Release 4.0 and later, the Appcelerator CLI handles the installation of the Titanium CLI.

Preparing for the Titanium CLI

Before installing and using the Titanium CLI, you need to install the Oracle JDK and Node.js.

Register for an AMPLIFY Appcelerator Services account.

If needed, install the Android SDK and NDK beforehand to help simplify the CLI setup process.

The Titanium CLI only supports Titanium SDK 3.x and later.

Install the CLI

  1. Install the titanium CLI.  On Mac OS X, you may need to prefix this command with sudo.

    npm install -g titanium
    
  2. Log in using your Appcelerator credentials.

    titanium login
    

    You are prompted for your AMPLIFY Appcelerator Services login and password.
     

  3. Install the latest released SDK.

    titanium sdk install
    
  4. Configure CLI.

    titanium setup quick

    The script prompts you to enter basic information, such as your name, AMPLIFY Appcelerator Services e-mail login, default locale, default SDK version, default workspace folder and Android SDK home directory.

Configure the CLI

Use the CLI setup wizard to quickly configure your CLI options and platform settings.  For example, running the titanium setup command with no options prompts you to enter basic information as well as your Android SDK home directory for Android development.  The following command prompts you for advanced CLI options and additional platform settings:

titanium setup

Use the CLI config command to selectively change your CLI options and platform settings.  For example, running the titanium config command with no options outputs your current configuration settings.  If you have already setup the Android SDK and NDK, the following commands set your Android platform settings (on a Mac OS X system):

titanium config android.sdk /Users/appc/sdk/android-sdk/
titanium config android.ndk /Users/appc/sdk/android-ndk-r8b/

Note: Not all platforms need to be configured.  For example, for iOS development, the CLI uses the xcode-select path to obtain the path to the Xcode development tools.

Update the CLI

To update the CLI tool, run the npm install command.  On Mac OS X, you may need to prefix this commands with sudo.

npm install -g titanium

To update the Titanium SDK, run the titanium sdk install command.  For example, running the command with no options installs the latest released version.  The following command installs the lastest continuous integration build and makes it the default SDK version:

titanium sdk install --branch master --default

Create a Basic Project

The following CLI commands create a basic project then builds it.  You need to have a platform SDK installed and configured, or else you can only build Mobile Web projects.  For the Android platform, you need to have previously created an Android virtual device (emulator).  To create a new emulator, see Native Android Debugging and Testing Tools.

When running these commands, you are prompted for missing information, such as the application ID and platforms, which may also be specified using command-line options.

titanium create --name MyFirstProject
cd MyFirstProject
titanium build

Next Steps

Review the Installing Platform SDKs to install additional development tools for mobile platform development and the Titanium CLI Tasks for using the CLI.

Related Links