Cross Platform Mobile
Development with
Appcelerator Titanium
/dev/summer, Cambridge - July 2014
Boydlee Pollentine
Author, Appcelerator Titan
Owner, Tipsy & Tumbler
Ltd
Organiser, tiConf.org
Twitter: @boydleep
Mobile development is cool.
iOS - Objective C & Swift
Android - Java
Mobile Web - HTML 5
Blackberry - Java
Windows 8 Mobile - C# / JavaScript
It’s a wide and varied landscape…
Text
…dominated by these two.
The Abstraction Layer
What's the point of an
abstraction layer?
Less code, quicker development time
Less (and simpler) maintenance
Re-use existing knowledge and libraries
Less training
Easier developer resource management
Titanium
Open Source
Code in JavaScript
It is NOT a HTML-5
Container
It is NOT a Generator
Javascript -> Bridge ->
Native
Advantages
Write-once
Deploy on multiple platforms
Native interface controls and
elements
Reduce maintenance
Simplify development processess
Utilise and build upon existing
JavaScript skills
Approved by Batman
Disadvantages
Less granuler control
Changes/bug fix delays
No paid support plans
for non-enterprise
Code Re-use
90-95% of all business logic / NON-UI code is re-
usable
80-85% of all UI code is re-usable
Titanium Alloy (MVC Framework) simplifies this
process
Poor JavaScript coding and developer practices will
lead to a poor app
Getting started
Visit www.appcelerator.com
Register a free developer account
Download Titanium Studio, which will attempt to walk
you through the iOS/Android pre-requisites.
These pre-requisites are the SAME as they are for
native developers!
Titanium Studio
But… Eclipse sucks!
Titanium CLI
Use your favourite code editor (Sublime, Atom,
etc)
Build, package, test and debug using the CLI
Built on Node.JS
Use it for scripting, automatic builds and
continuous integration
What’s the code look like?
Text
Titanium “Classic”
All UI elements, layouts and logic are defined by
code.
Text
Titanium Alloy
Projects are split into Controllers (JS), Models
(JS), Views (XML) and Styles (TSS)
Titanium Alloy vs “Classic”
Not all or nothing - you can mix and match the classic
UI coding approach with Titanium Alloy
Using Alloy will help you ensure CommonJS
consistency across screens/windows. If you’re unsure
about how to structure an app - use Alloy.
Alloy is essentially just a pre-compiler - do a build and
view the “Resources” folder!
Common JS
Standardised format for JavaScript modules and code
re-use
CommonJS patterns fix the “memory issues” often
associated with Titanium (usually by people who can’t
code particularly well)
Re-use in Node projects, package re-usable chunks
into a Titanium Module for multiple projects
TSS Styles - similar to CSS
Similar structure (but not the same) as CSS
#idName denotes an ID
.className denotes a class
Use Ti.UI.FILL and Ti.UI.SIZE wherever possible - not
percentages
You can reference global variables (i.e. color names) by
referencing Alloy.Globals (i.e.
Alloy.Globals.myStyles)
Conditional Platform
Handling
In code:
if(Titanium.Platform.osname == ‘android’) {
if(OS_IOS) {
if(ENV_DEV || ENV_TEST) {
In TSS:
“#myView[platform=android]” {
width: Ti.UI.FILL,
height: 200
}
Conditional Platform Assets
Everything in your assets folder can be broken down into
platform-specific content.
Don’t go copying up @2x and other retina images meant
for iOS into your Android project - use the assets/iphone
folder!
Using font-icons where possible will reduce build size
The main reason Titanium app package sizes are large is
because of ASSETS!
Native modules
allow you to
extend the
Titanium Platform
Augmented Reality
Barcode scanning
Third-party services
(VOD, ArcGIS, Video
Chat, etc)
Lanica Platino
2D game engine
Javascript
From £48.95 p/a (with a
free trial)
Cross platform - iOS &
Android
Use with Titanium code
Appcelerator Cloud
Services
Free MBaaS platform (similar to Kinvey & parse.com)
Generous free limits
Integrated modules for users, places, posts, emailing,
reviews, etc
Built for “social” applications
Push notifications built-in (1 million per month free)
Appcelerator Enterprise
Paid support
“Appcelerator Studio” with Liveview, Insights,
Analytics suite and more
Large, scalable Appcelerator Cloud MBaaS
infrastructure
Made for Enterprise
tidev.io
ticonf.org
Appcelerator Q&A
Additional Resources
gitt.io
docs.appcelerator.com
Appc. Marketplace
Questions?

Dev summer-keynote