tiapp.xml
This file lives in the base directory of your project and contains your global project settings and compile-time customizations. Titanium Studio provides a clean, simple overview interface to the main settings listed in the file, as shown in the screenshot under step 3 of the Time for action – creating an app from a template section. From the overview screen you can:
Add new external modules to your project such as a Twitter or PayPal module extension
Add Appcelerator cloud services
Change the Titanium SDK used to compile your app
Enable deployment targets for supported platforms
Change app version, description, and publisher details
When you open the tiapp.xml
file you will notice that along with the overview there is a set of tabs at the bottom of the screen, which allows you to switch between the overview and the raw XML. There are a number of things that you can only change from the raw XML view of the file, for example allowed orientations, so it's worth getting familiar with it. The table given next provides a list of most configurable items within the file. You don't need to examine and learn the options now, in fact it doesn't make for great reading; you can refer to it when you need it. We will look at the effects of some of the settings later in the book.
tiapp XML structure explained
XML |
Description |
---|---|
<?xml version="1.0" encoding="UTF-8"?> <ti:app xmlns:ti="http://ti.appcelerator.org">
|
This is the standard XML header. |
<deployment-targets> <target device="mobileweb">false</target> <target device="iphone">true</target> <target device="ipad">false</target> <target device="android">true</target> <target device="blackberry">false</target> </deployment-targets>
|
This is the list of supported devices. This can be changed from the overview screen. |
<sdk-version>3.0.0.GA</sdk-version> <id>com.mycompany.firstapp</id> <name>FirstProject</name> <version>1.0</version> <publisher>Darren</publisher> <url>http://</url> <description>not specified</description> <copyright>2012 by Darren</copyright> <icon>appicon.png</icon>
|
These settings can be changed from the overview screen. |
<persistent-wifi>false</persistent-wifi>
|
Does your app require a persistent Wi-Fi connection, or is the default that turns off after a period of inactivity ok? |
<prerendered-icon>false</prerendered-icon>
|
This controls the shine/gloss effect that is added to icons on iOS. Setting this to |
<statusbar-style>default</statusbar-style>
|
This is the status bar style. See |
<statusbar-hidden>false</statusbar-hidden>
|
Should the status bar be hidden? |
<fullscreen>false</fullscreen>
|
Should the app start up using the full screen? |
<navbar-hidden>false</navbar-hidden>
|
Should the navigation bar be hidden? |
<analytics>true</analytics>
|
Do you want to gather analytic information about the app that will be automatically uploaded to the Appcelerator site? |
<guid>d047116f-4ddb-4007-a24f-8702df42e59e</guid>
|
This is the unique internal identifier of your app. It is used with the analytics services. Do not change this value. |
<property name="ti.ui.defaultunit">system</property>
| |
<iphone> <orientations device="iphone"> <orientation>Ti.UI.PORTRAIT</orientation> </orientations> <orientations device="ipad"> <orientation>Ti.UI.PORTRAIT</orientation> <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation> <orientation>Ti.UI.LANDSCAPE_LEFT</orientation> <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation> </orientations> </iphone>
|
This lists the allowed orientations for the iOS devices you support. The options shown to the left restrict any displays on an iPhone to portrait (that is with the button at the bottom of the phone). All orientations will be supported by the iPad. |
<android xmlns:android="http://schemas.android.com/apk/res/android"/>
|
This lists compile-time directives for the Android generator if any. This is also where any |
<mobileweb> <precache/> <splash> <enabled>true</enabled> <inline-css-images>true</inline-css-images> </splash> <theme>default</theme> </mobileweb>
|
These are the settings and controls for the generation of a mobile web app. |
<modules/>
|
Any external modules added to the project will be listed here. This can all be done from the overview screen. |
</ti:app>
|
This is the closing XML line. |
The good news is that for this chapter you don't have to change any of these settings.
Other files in the base directory
There are several other files that were generated when the project was created.
The other files in the project root directory are all text files that do not affect the operation of the app. They will be bundled with your app when it is released. You can update them if you feel the need.
The Resources directory
The other main element created at project inception is the Resources
directory that looks as follows:
It contains one important file, app.js
.
app.js
app.js
is the entry point of any Titanium
project—the first line of code that is executed. It can be freely edited as you wish. We will look at the contents of this file in later chapters. For now just accept the contents of the file that have been generated.
KS_nav_ui.png and KS_nav_views.png
KS_nav_ui.png
and KS_nav_views.png
are the two icons that appear at the bottom of the screen on the tabs. They are needed for this app but are not important elements of other apps. They can be deleted if they are not used.
The Android and iPhone directories
The android
and iphone
directories under
the Resources
folder contain the app icons and splash screens for many different iOS and Android devices supported by your app. We will look in more detail at the contents of these directories in Chapter 11, Testing and Deploying.
Pop quiz - Titanium installation and configuration
Q 1. You want to develop apps on your windows PC using Titanium. What platforms can you test on the machine?
iOS
Android
Symbian
Q 2. You will often need to refer to the app configuration file to change settings. Where can you find it?
<project base directory>/manifest
<project base directory>/resources/app.json
<project base directory>/tiapp.xml
<project base directory>/app.js
Q 3. What is the name of the source code file that is first run when an app starts?
<project base directory>/app.js
<project base directory>/resources/app.js
<project base directory>/init.js
<project base directory>/build/start.exe