Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
348 lines (258 sloc) 13.5 KB

From zero to app

How to install Axway Appcelerator in combination with Atom

Since Axway Titanium SDK 6.0.4.GA, the "Indie Tear" is now free and you can get the latest SDK and use Hyperloop. This tutorial will get you started setting up Axway Titanium and use it in combination with Atom as an editor on Linux, Windows and macOS (you could use other editors like Sublime or Visual Studio Code but that's not part of this tutorial).

main view

Table of Contents generated with DocToc

Installing Appcelerator Titanium

The current GA ('general availability') version of the SDK was 7.1.0.GA.

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


Linux

Fedora

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

# install tools and libraries
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

Ubuntu

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

For all Distros (if you don't have Node.js v8.x)

If you do not have node v 8.x already you can up/downgrade with n

# install npm version 8.x
npm install -g n
n 8.10.0
 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
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-adm64 # ubuntu
  • run source .bash_profile to update the current session

Windows

Node.js

Go to https://nodejs.org/download/release/v8.10.0/ and download NodeJS v8.10.0. If you already have a different version installed you can use nvw-windows (https://github.com/coreybutler/nvm-windows/releases) to change this version to v8.10.0.

nvm install 8.10.0   # install a new version with nvm
nvm use 8.10.0       # set it

Java JDK

Download and install JDK 8 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\jdk1.8.0_45)

Android SDK

Go to https://developer.android.com/studio/index.html#downloads and download the ZIP under "Get just the command line tools".

Unzip and copy it to a folder (e.g. C:\android). Then go into the folder and run

sdkmanager --update
sdkmanager "platforms;android-23" "build-tools;23.0.3" "extras;google;m2repository" "extras;android;m2repository"
sdkmanager --licenses
  • Android SDK tools
  • Android SDK Platfom-tools
  • Android SDK Build tools (23.0.3)
  • Android 6.0 (API 23) SDK Platform
  • other APIs if you like

Download the ADB tools from https://dl.google.com/android/repository/platform-tools-latest-windows.zip and unzip it to the androidsdk folder from before. Add the following paths to the PATH env variable:

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

macOS

Node.js

  • Fresh install: Go to Nodejs.org and download the v8.10.0 (LTS).
  • Upgrade: Install the Node version manager n and update to the LTS:
npm install -g n
n lts

Axway Titanium SDK / CLI

Open a console and run the following command to install the tools:

npm install -g titanium alloy appcelerator

After that we need to install the SDK.

Free Version

If you use the free/indie version, you can run

appc setup

to get the SDK and be ready to create your apps

Open Source Version

If you prefer the open source version, you run:

titanium sdk install --branch 7_1_X

to get the SDK (it won't be the GA version but the latest from the 7.1.x branch) and then

 ti config wizard

to finish the setup. Note: As of right now (03/2018), the current latest it 7.1.0 GA. You can check the latest GA version by going to the Titanium Build Server to select the latest one.


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

Then install some Atom packages for easier Titanium coding:

Name Type Features
Appcelerator Titanium IDE IDE Official Atom package by Axway
titanium Language JavaScript Language JS Autocomplete (non alloy)
Titanium Alloy add-on All-in-one package
Jump to definition
Open related
TSS Highlight

Other useful non-Titanium packages/add-ons:

Name Features
Atom Beautify Code beautifier (tss, xml, js support)
DocBlockr A helper package for writing documentation
highlight-selected Highlights the current word selected when double clicking
Linter-jshint Linter plugin for JavaScript (this checks your JS code)
Linter A Base Linter core with Cow Powers (does nothing by itself, it's an API base)
minimap-highlight-selected A minimap binding for the highlight-selected package
minimap A preview of the full source code.
pigments A package to display colors in project and files.
Platformio-ide-terminal An active fork from previous terminal package for Atom, running in newer versions, complete with themes and more
Project Manager Project manager
symbols-list Will display all functions in a sidebar
sync-settings Syncs Atom settings, plugins etc using Gists. Very handy if you have multiple machines and want to have the same settings everywhere
Terminal-plus A terminal package for Atom, complete with themes and more. NOTE: will probably fail with newer Atom versions, try next
auto-close-html2 Automatically 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 :

appc new

(for the OSS you change appc new to 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

main view

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
appc ti build -p android  -T device

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

# android to store/file
appc 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
appc ti build -p ios -C ?

# iOS ipa/device/store: will show you a menu to select the different profiles
appc 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='appc ti build -p android  -T device --skip-js-minify'
# Distribute Android for Google Play, specify the required keystores
alias tbs='appc 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='appc ti build -p android --build-only'

# Run on iOS, specify a device
alias tq_ios='appc ti build -p ios -C ?'
# Distribute iOS for the App Store
alias tq_ios_store='appc 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.


Link List

Here are some useful Titanium resources:

Contact me

Feedback appreciated.