You must have the following software installed to be able to compile the Titanium SDK. (Click on any item to get instructions on how to install it for your system.)
The following software is required for building Titanium applications, and you probably already have it installed:
The following additional software is required for building the Titanium SDK:
Many of these items you may already have installed for developing Titanium applications.
To build the SDK for Android, you must have either Apache Ant or Eclipse and ADT installed. In most cases, you should probably have both--Ant for command-line builds, and Eclipse and ADT for interactive builds and debugging. Building the SDK using
scons, as described here, requires Ant.
For Windows, if you use Studio, you may need to reinstall some of the tools, such as Git, Java and Node.js, and modify your PATH variable to the new locations of the binary executables. Paths to tools should not contain spaces.
Setting Up Your Environment
The following environment variables must be set in order to build the SDK from source.
Android SDK directory, for example,
Android NDK directory, for example,
|JAVA_HOME||Oracle JDK directory, for example, C:\Java\ jdk 1.8.0_121|
Getting the Source
The simplest way to get the SDK source is to simply clone it:
However, if you have any interest in contributing to Titanium, you should create your own fork of the
titanium_mobile repository on github, as described in the Pull Request Guide.
Checking Out a Pull Request Locally
If you want to test a changes that is a pull request on Github, you can add and checkout remote PR branches to your local titanium_mobile repo. Note that there are over 10000 PRs in the titanium_mobile Github repo, and over 10000 remote PR branches will be linked to your local repo. They will not be downloaded until you explicitly clone them.
To add the remote PR branches:
- From the root level of your titanium_mobile repo, open the
Locate the appcelerator/titanum_mobile repo contents in the file. Note that the remote repo name will be different depending on how you retrieved the appcelerator/titanum_mobile remote repo. In the example below, it was name "upstream".
Add the following line to the section and replace
<remote_name>with the name of the remote repo:
In the previous example, the section now looks like:
Fetch the remote PR branches:
Checkout the PR you want to test:
To remove the PR remote branches, run the following command:
Build the SDK
The method written below is the old way. The repo has now been updated to do away with scons. Please refer to https://github.com/appcelerator/titanium_mobile/blob/master/README.md#building-locally on how to build locally with Node.JS scrips.
In the root of your
titanium_mobile repo, run the following commands:
By default, the above will build the SDK for all platforms. You can specify platforms to limit the generation of unmentioned platforms, e.g.
node scons.js cleanbuild ios.
When updating to a new version of the SDK, it is usually necessary to rerun
npm install to update the local Node dependencies.
Installing a Built SDK
Once you've built the SDK successfully, the built SDK is in
titanium_mobile is the root of your local repo,
<version> is the current version of the SDK master branch, and
<os> is the OS you built for,
osx. By using the above Node commands, the SDK will automatically installed for you. To manually install a packaged SDK,
select one of the following options:
To Install the SDK Using Studio
Note that if you install an SDK using Studio, it will appear in Studio with the default version number. If you want to rename your custom SDK, see To Install the SDK Manually.
- Click Help > Install Titanium SDK....
- Select Install from URL.
- Click Browse. Browse your
<titanium_mobile_dir>/distfolder and select the zip file.
- Click Finish.
To Install the SDK Manually
- Unzip the zip file.
- Inside the
mobilesdk/<os>folder, there is a folder named with the version number (for example, 7.2.0). You may want to rename this folder so you can distinguish it later – for example, 8
- Copy the SDK folder to the folder where your other Titanium SDKs are installed.
The default installation folder for SDKs varies by operating system:
Speeding Up the Titanium SDK Build
The process of compiling the Titanium SDK source code can be very time consuming if your environment is not primed to do so. Here's a short list of tips and tricks for getting that compile time down. In our testing so far, these tips can reduce compile time by as much as 80%!
The Android NDK can use ccache, a tool for reusing cached C/C++ compilations. We get huge improvements in build time with it.
- Install HomeBrew if you don't have it installed already
ccachewith the following command:
brew install ccache
- Set an environment variable
NDK_CCACHEto point to it. Installed with HomeBrew, the command would be:
The NDK can also parallelize while compiling, which can speed up the process.
- Determine how many cores your machine has. You can use this command on macOS:
system_profiler | grep -i "Number Of Cores"
- Multiply the above number by 2. So if the above command returned
Number of Cores: 2, then your value should be 4.
- Set an environment variable
NUM_CPUSequal to the above value. In this case: