Titanium 시작하기

공부를 해보자/안드로이드 2010. 5. 28. 15:18
http://developer.appcelerator.com/doc/mobile/get_started

Getting Started with Titanium Mobile

Pre-Requisites

For iPhone/iPad App Development

Get the latest iPhone SDK from Apple's iPhone Dev Center. The standard SDK download will include XCode and all the other development tools that we require. Note: You need at least iPhone SDK 3.2 if you want to develop for both the iPhone and the iPad.

For Android App Development

Install the Android SDK. When running the Android SDK setup program (called the "Android SDK and AVD Manager"), be sure to install "SDK Platform Android 1.6, API 4". You may also install more recent platforms (such as 2.1), but 1.6 is an absolute requirement for Titanium. Also install the "Google APIs" package(s) so that you can run the KitchenSink (our sample application that shows off Titanium functionality) and use the Google Maps API.

Install the latest Sun/Oracle Java Development Kit. JDK 6 (aka Java 1.6) is the minimum requirement for Titanium. On Windows, please set a JAVA_HOME environment variable to point to your JDK installation, or change your PATH to include a directory that includes java.exejavac.exe, and jarsigner.exe.

Download and Install

After installing Titanium Developer, you should start the Titanium Developer product and see the following welcome screen:

login

If you already have an existing Appcelerator Network login, you can use those credentials to login. If not, you'll need to create an Appcelerator Network login. These credentials will give you access to a number of resources like Developer Center (this site) as well as access to cloud services like analytics.

Initial Project

Once you're logged in, you'll be able to create your first mobile project. Click the "New Project" button, select "Mobile" from the Project type drop down and you should see the following:

newproject

When you first enter the screen, the system will first check and make sure you have at least one mobile platform available before continuing. For Android, if you don't have the Android SDK on your PATH or it cannot be located, Developer will ask you for the installation location. Also, make sure that you have your Java SDK on your PATH environment as well.

Project fields

  • Name - the name of your project or application.
  • App Id - this must be a unique ID for your project. This is usually a namespace URL such as com.yourcompany.name. For iPhone, this must also match your iPhone provisioning id.
  • Directory - this is the directory (top level) to install your project. The full path to your project is directory/project_name.
  • Company/Personal URL - this is your URL
  • Titanium SDK version - the version of the Titanium Mobile SDK to use. This provides you will the ability to use different versions of the SDK for different applications.

Once you've filled out the required fields, you will be able to press the Create Project button to continue. Developer will create all the necessary files for your project for the available mobile platforms detected.

Verify the Sample Project

After you've created your new project, you should verify that everything is working. Click the Test & Package button in the middle of the project screen and you should see the following:

test_package

Verify for iPhone (if installed)

Click the tab that is labeled Run Emulator and then click the Launch button. After a few seconds, it will compile your application and launch it on the iPhone simulator and you should see:

iphone_emulator

Verify for Android (if installed)

Click the tab that is labeled 'Run Android Emulatorand then click theLaunch App` button. The Android emulator takes a considerable more time to start than the iPhone emulator. It generally takes 2-3 minutes to start the Android Emulator environment. However, once started, you can re-launch apps without having to restart the emulator (as long as you don't stop it).

android_emulator

What next?

Now, you're ready to start looking at code. Let's look at your application project.

There are a number of files and important folders in your mobile project. Here's the main files:

  • LICENSE - this file just describes the Appcelerator license. This is for your reference and not included in your application.

  • LICENSE.txt - this is your end-user application license. This is not currently used for mobile project but will be used in the future.

  • README - this file just describes the project and is not included in your application.

  • tiapp.xml - this is the main application descriptor file and describes details about your application and is used by the packager and the runtime.

  • manifest - this file is used by the packager and generally does not need to be modified.

  • build - this directory is where phone-specific project files and resources are kept. This folder is used by the packager and by developer for building, compiling and creating your native distributions. Generally, files in this folder should not be modified as this files are changed on demand by Titanium as your application changes. Use caution when touching any files or folders in these directories as it may render your application unusable.

  • Resources - this folder is very important and contains all your application files such as your JavaScript, HTML, images, etc. This is the main folder you will use to include resources for your application. All files included in this folder are packaged and available to your application.

Special resources per platform

There are a few specific folders under Resources that are special based on the final application package. Underneath the Resources folder is aniphone and android folder (dependent on which platforms you're using). All files placed under these folders will only be available on the platform by name. The files in these folders will take precedence (and will be merged) over files in the root Resources directory.

For example:

If you have a file named foo.png in the root folder and a file named foo.png under Resources/iphone - when Titanium compiles the application for iphone, you will have one file named foo.png which will be the file under the Resources/iphone directory. Directories are preserved during merging. This capability gives you more fine grain control over resources per platform in cases where you need to override or provide specific resources for a given platform. When you reference a file from your application, you should not include the platform in the name. For example, you would reference foo.png instead of iphone/foo.png since the files are merged into the base directory when packaged.

Default splash screen

To specify a default splash screen that is displayed as your application is loading, you need to replace the file named Default.png. For iPhone, you should take care to design a splash screen that will allow the spinner indicator to display near the center of the screen while loading.

Application icon

The application icon (what's shown on the phone screen) is controlled by the <icon> entry in the tiapp.xml file. The file is relative to theResources directory. You can specify a different icon for Android and iPhone by naming the file the same but including a different version in the respective platform folder under Resources.

Application Configuration

Most of the application configuration can be configured through Titanium Developer. However, there are a few application specific settings you'll need to edit directly in tiapp.xml.

iPhone specific configuration

There are a few additional iPhone specific configurations that control features or capabilities only available on iPhone.

  • persistent-wifi - this tag at the root level named <persistent-wifi> will tell iPhone that your application requires a persistent wifi connection and to not turn off the wifi after a brief period of inactivity. This defaults to false.

  • prerendered-icon - this tag at the root level named <prerendered-icon> will tell iPhone not to apply an additional gloss over your application icon. This is useful if you have a pre-rendered gloss that has been applied. This defaults to false.

: