How to install Titanium to start building mobile apps

This tutorial will get you started setting up Titanium and use it in combination with Atom as an editor on Linux, Windows and macOS. You can also use it with VSCode and the VSCode package.

Installing Titanium

The current GA (‘general availability’) version of the SDK is 11.0.0.GA.

At first we need to setup Appcelerator Titanium:

  • command line tools (CLI) to compile the apps
  • the MVC framework Alloy
  • some useful tools
  • the SDK

The main parts are installed using the node.js package manager ‘npm’. Check https://nodejs.org/ if you need to install it.

General installation

The following parts are necessary to run Titanium:

  • node.js v16
  • titanium / alloy node packages
  • java jdk (11 or 16)
  • xcode
  • Android SDK (we’ll use Android Studio to install everything)

Node.js

At first you need node.js v16 (https://nodejs.org/). After that you can use npm to install the packages as a global package:

sudo npm i -g titanium alloy

Then you can use

ti sdk install latest

to install the latest Titanium SDK.

Java

Install JDK (e.g. openjdk) 11 or 16.

Android SDK

The Android SDK is necessary if you want to compile an Android app. There are two ways to install it:

Android Studio
Download Android Studio and let it handle the SDK install.
If you are using the latest version of Android Studio to fetch the SDK and the needed tools make sure to uncheck Hide Obsolete packages and install the SDK tools. You might also need to copy the content from /platform-tools/platform-tools/bin to /platform-tools.

manual way
Check https://github.com/tidev/titanium_mobile/blob/10_0_X/android/package.json#L29-L34 for the current supported versions.
Go to https://developer.android.com/studio#cmdline-tools and download the ZIP for your platform.

Unzip and copy it to a folder (e.g. C:\android or /home/user/android). Then go into the folder \tools\bin and run

sdkmanager --sdk_root=/home/user/android/ --update
sdkmanager --sdk_root=/home/user/android/ "extras;android;m2repository" "platforms;android-29" "build-tools;28.0.3" "platform-tools"
sdkmanager --sdk_root=/home/user/android/ --licenses
  • Android SDK tools
  • Android SDK Platfom-tools
  • Android SDK Build tools (28.0.3)
  • Android 10.0 (API 29) SDK Platform
  • other APIs if you like

Download the ADB tools from :

Add the following paths to the PATH env variable:

  • C:\android\
  • C:\android\platform-tools

Platform specific

Linux

If you are using Fedora 26+ you can run the following commands to get the needed libraries:

# install tools and libraries
sudo dnf install nodejs npm git gcc glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686 java-11-openjdk

Ubuntu looks like this:

sudo apt-get install nodejs npm git gcc  gcc-multilib openjdk-11-jdk android-tools-adb

Adjust you .bash_profile:

export PATH=$PATH:$HOME/android-sdk-linux/tools:$HOME/android-sdk-linux/platform-tools:/usr/java/latest/bin
export ANDROID_SDK=$HOME/android-sdk-linux

export JAVA_HOME=/usr/java/latest # fedora

and run source .bash_profile to update the current session

Windows

Powershell

You can use this PowerShell file to install all tools. Run it in a admin PowerShell and make sure to enable the Windows dev mode in the Windows settings.

manual way

  • enable “dev mode” in Windows in the security settings to run node scripts
  • download OpenJDK from https://jdk.java.net/archive (11.0.2)
  • extract the ZIP to e.g. c:\programms\java\jdk-11.0.2
  • set system JAVA_HOME variable to the same folder
  • restart command prompt

Java

Download and install JDK 11 from http://www.oracle.com/technetwork/java/javase/downloads/index.html and set the JAVA_HOME env variable inside the windows advanced system settings (e.g. C:\Program Files\Java\jdk11)

macOS

Android Studio

If you use macOS Big Sur you’ll need to run defaults write com.google.android.studio AppleWindowTabbingMode manual in a console so Android Studio 4.1.2 won’t freeze when you create an AVD or download extra SDKs.

Java JDK

You can use brew install openjdk@11 or if you use a M1 Mac you can use the version from https://github.com/microsoft/openjdk-aarch64/releases/tag/jdk-16.0.2-ga

List available Java JDK installations:

/usr/libexec/java_home -V

select a version

export JAVA_HOME=$(/usr/libexec/java_home -v <JdkVersionYouWant>)

and put that in your .bash_profile or .zprofile

export JAVA_HOME=$(/usr/libexec/java_home -v 16)

If you are using a M1 Mac you have to use this version: openjdk-aarch64
Homebrew’s version only goes up to v11 and Oracle’s v17 is not supported.

XCode

If you have issues with XCode like Unable to find an iOS Simulator check Xcode preferences->locations->Command Line Tools and make sure it is set.

Install Atom (and some useful Packages)

Windows / macOS:

Go to https://atom.io/ and install the Atom editor.

Linux (Fedora):

sudo dnf install $(curl -sL "https://api.github.com/repos/atom/atom/releases/latest" | grep "https.*atom.x86_64.rpm" | cut -d '"' -f 4)

Packages

The official Appcelerator IDE package is called:

NameTypeFeatures
Appcelerator Titanium IDEIDEOfficial Atom package

There are some other (older) packges which are not needed when installing the official one. But it is worth mentioning them:

NameTypeFeatures
titanium Language JavaScript (old)LanguageJS Autocomplete (non alloy)
Titanium Alloy (old)add-onAll-in-one package
Jump to definition
Open related
TSS Highlight

Other useful non-Titanium packages/add-ons:

NameFeatures
Atom BeautifyCode beautifier (tss, xml, js support)
DocBlockrA helper package for writing documentation
highlight-selectedHighlights the current word selected when double clicking
Linter-jshintLinter plugin for JavaScript (this checks your JS code)
LinterA Base Linter core with Cow Powers (does nothing by itself, it’s an API base)
minimap-highlight-selectedA minimap binding for the highlight-selected package
minimapA preview of the full source code.
pigmentsA package to display colors in project and files.
highlight-colorsAlternative way to display colors in your code.
color-pickerUse a color picker dialog to select a color.
Platformio-ide-terminalAn active fork from previous terminal package for Atom, running in newer versions, complete with themes and more
Project ManagerProject manager
symbols-listWill display all functions in a sidebar
sync-settingsSyncs Atom settings, plugins etc using Gists. Very handy if you have multiple machines and want to have the same settings everywhere
Terminal-plusA terminal package for Atom, complete with themes and more. NOTE: will probably fail with newer Atom versions, try next
auto-close-html2Automatically close XML tags

Create your first App

For this tutorial we are just creating an empty Alloy app using CLI and Atom.

Open a new terminal and add the following :

ti create

You will see a menu where you can select “Native app – Titanium SDK – set a project name – set an app id”.
For the beginning, say no to the Test-service and Hyperloop.

You can also use the Atom package ti-create

It will create a new project inside the folder that is open in the tree-view. ‘Create controller/widget’ only work inside an existing Alloy project (“Open folder” – select the project folder).

Compile your app

There are several ways to compile your app. You can use the simulator/emulator, deploy it to your device or create store apk’s/ipa’s. There is also a live test tool (TiShadow) which saves you a lot of time waiting for the compiler.

The CLI Way

# android to device
ti build -p android  -T device

# android build-only (good for testing)
ti build -p android -b --skip-minify

# android to store/file
ti build -p android -K /home/user/keyfile.keystore -T dist-playstore

# iOS simulator: will show a menu to select the size/device (e.g. press 8 for iPhone 5S
ti build -p ios -C ?

# iOS ipa/device/store: will show you a menu to select the different profiles
ti build -p ios --target ?
iOS related

To list all distribution names you can use:

security find-identity -v -p codesigning

Shortcuts

You can save yourself a lot of typing when you define some aliases (e.g. ‘tq’ will run the whole ti command to compile it and deploy it to the connected android device).

Linux / macOS

In Linux/macOS you open the .bashrc file and add the following aliases:

# Run on Android device, skip minification to speed up the build
alias tq='ti build -p android  -T device --skip-js-minify'
# Distribute Android for Google Play, specify the required keystores
alias tbs='ti build -p android -K /home/user/keyfile.keystore -T dist-playstore'
# Create an Android APK without installing it to the device. Grab from build/android/bin
alias tq_only='ti build -p android --build-only'

# Run on iOS, specify a device
alias tq_ios='ti build -p ios -C ?'
# Distribute iOS for the App Store
alias tq_ios_store='ti build -p ios --target dist-appstore'

then you can just write “tq” to compile and install on your connected device or write “tbs” to build an apk for the play store.

Windows

In Windows, the basic aliases command is not enough (you can’t attach options in alias), so you must use .bat files or, a better solution, powershell aliases+functions. As you may want to have it permanently on your shell session, first you must create a powershell session file, the equivalent to .bashrc on Linux. So, open a PowerShell command line and do:

NOTE: You should need to activate the execution policy allowing scripts locally in order this solution to work. Open the powershell command line as administrator and type set-executionpolicy remotesigned

# Checking if profile exists
PS C:\> $profile
# If you cannot see/access the indicated folder, force the creation
PS C:\> New-Item -path $profile -type file -force

Ok, now you can open the Microsoft.PowerShell_profile.ps1 file and create your functions+aliases

Function appcBuildAndroid {ti build -p android -T device --skip-js-minify}
New-Alias tib appcBuildAndroid

Function appcBuildPlayStore {ti build -p android -K C:\Android\Mykeys\keyfile.keystore -T dist-playstore}
New-Alias tibs appcBuildPlayStore

The next time you open a PowerShell console, you will have available the aliases tib and tibs to compile for Android or for Play Store. Of course they are examples. Do as many as you want.

Here you can see a Windows Power Shell profile example, preconfigured: https://gist.github.com/mcvendrell/b4bacd36b834303a4e5f61afc947706a

TiShadow

TiShadow is another great tool by David Bankier (https://github.com/dbankier/TiShadow)

TiShadow provides Titanium developers the ability to deploy apps, run tests or execute code snippets live across all running iOS and Android devices.

It allows you to quickly test your app on multiple devices at the same time and ‘compiles’ quicker then building your app all the time (about 5 seconds to get your app up and running on an android phone, for a small app). Also it works over wifi, so you don’t have to have your device connected.

Liveview

You can add --liveview to compile with liveview from command line

Link List

Here are some useful Titanium resources:

Like the content?

If you like the tutorials, plug-ins or want to see more please consider becoming a Github sponsor.

Content