Getting started with Appcelerator Titanium (OSS Version) and Atom (Mac OSX)

abada
All Titanium
4 min readJan 18, 2016

--

This is a repost of the original at http://m1ga.github.io/titanium_with_atom/

Since version 4 of Appcelerator Titanium there are two version of Titanium: the ‘Appcelerator Platform’ (with Appcelerator Studio, Arrow,..) and the open source version ‘Appcelerator Titanium’ (http://appcelerator.org/). In this tutorial I’m talking about a way to get started with the open source Titanium in combination with Atom as an editor on Linux (you could use other editors like Sublime, but that’s not part of this tutorial).

Installing Appcelerator Titanium

The current free ‘general availability’ version of the SDK is 5.1.2.GA

At first we need to setup 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.

Now open a console and run the following command to install the tools:

npm install -g npm
npm install n -g
npm install -g titanium alloy appcelerator tisdk

After that we need to install the SDK. To do this we will the cli tool tisdk from David Bankier (https://github.com/dbankier/tisdk):

# list available titanium sdks
tisdk list

The output will be something like this

5.1.2.GA5.1.1.GA5.1.0.GA
...

From this list we select the latest GA (5.1.2) and istall it

tisdk install 5.1.2.GA

with this command you can check if titanium found the sdk:

ti sdk list

and with

ti info

you can see if something is missig (How to install JDK and the Android SDK will follow)

You are ready to create titanium/alloy projects now and compile them! Time to setup the editor

For more information visit https://github.com/dbankier/tisdk and have a look at “Manual builds”

other method

Codexcast released a video about “Getting Setup With Titanium Mobile OSS: including compiling the SDK

Install atom and some useful packages

Goto https://atom.io/ and install the atom editor.

Then install some Atom packages for easier Titanium coding:

NameTypeFeaturestitanium language javascriptLanguageJS Autocomplete (non alloy)Titanium Alloyadd-onAll-in-one package
Jump to definition
Open related
TSS HighlightTi-Createadd-onCreate projects, controller, modulesTitanium-Buildadd-onRun in simulator (wip)

Other useful non-titanium packages/add-ons:

NameFeaturesAtom BeautifyCode beautifier (tss, xml, js support)minimapA preview of the full source code.minimap-highlight-selectedA minimap binding for the highlight-selected packagehighlight-selectedHighlights the current word selected when double clickingpigmentsA package to display colors in project and files.LinterA Base Linter with Cow PowersProject ManagerProject manager

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 --id com.test -d . -n APPNAME -p all -t app -u http://migaweb.de
cd APPNAME/
alloy new

This will create a basic app (name: APPNAME, bundle identifier: com.test, type:app, platform: all) and the convert it into an Alloy project.

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.

cli way

# android to device
ti build -p android -T device
# 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
ti build -p ios -C ?
# iOS to ipa - will show a menu to select the keys
ti build -p ios --deploy-type production --ios-version 9.0 --keychain --target dist-adhoc --output-dir .

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) In Linux/OSX you open the .bashrc file and add the following aliases:

alias tq='ti build -p android  -T device --skip-js-minify'
alias tq_ios='ti build -p ios --deploy-type production --distribution-name "DIST_NAME" --ios-version 8.4 --keychain --pp-uuid PROF_ID --target dist-adhoc --output-dir .'
alias tbs='ti build -p android -K /home/user/keyfile.keystore -T dist-playstore'
alias tq_select='ti build -p ios -C ?'

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.

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.

Link list

Here are some useful Titanium ressources:

Original post https://github.com/m1ga/titanium_with_atom

--

--

abada
All Titanium

Full stack developer + Mobile Apps …… ¯\_(ツ)_/¯