Titanium CLIを使ってみる

Titanium Mobileの復習をしてみたいと思います。

まずは、開発環境を構築しますが、今回はコマンドラインでの構築ツールである Titanium CLIを使います。

インストールにはnodeのパッケージ管理ツールであるnpmを使用しますのであらかじめインストールしておきます。

$ npm install titanium
$ titanium
Titanium Command-Line Interface, CLI version 3.0.18, Titanium SDK version 3.0.0.v20121017192538
Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.

Please report bugs to http://jira.appcelerator.org/

Usage: titanium <command> [options]

Commands:
   build     builds a project
   clean     removes previous build directories
   config    get and set config options
   create    creates a new mobile application or module
   help      displays this help screen
   info      display development environment information
   login     logs into the Appcelerator network
   logout    logs out of the Appcelerator network
   module    manages installed Titanium Modules
   plugin    manages installed Titanium Plugins
   project   get and set tiapp.xml settings
   sdk       manages installed Titanium SDKs
   setup     run the setup wizard
   status    displays session information
 
Global Flags:
   --banner, --no-banner   displays Titanium version banner  [default: true]
   --colors, --no-colors   use colors in the terminal  [default: true]
   -h, --help              displays help 
   --prompt, --no-prompt   prompt for missing options  [default: true]
   -q, --quiet             suppress all output 
   -v, --version           displays the current version 

インストールが終わったらまずは設定をします。

$ titanium setup
Titanium Command-Line Interface, CLI version 3.0.18, Titanium SDK version 3.1.0.v20121121154400
Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.

Please report bugs to http://jira.appcelerator.org/

Enter ctrl-c at any time to quit

What is your name? (this is used as the default for the "author" field in the tiapp.xml or module manifest file when creating new projects) (xxxxxxxx) 
What is your email address used for logging into the Appcelerator Network?  (xxxxxxxx@gmail.com)
What would you like as your default locale? (examples: "en", "de", "fr") (ja) 
What Titanium SDK would you like to use by default? (3.1.0.v20121121154400) 
Path to your workspace where your projects should be created: (/home/xxxxxxxx/Titanium_Studio_Workspace) 
Path to the Android SDK: (this is needed for building Android apps) (/home/xxxxxxxx/android-sdk-linux) 

Configuration saved

setupで聞かれる内容は
1. What is your name?
 tiapp.xmlのauthorフィールド、またはmoduleマニフェストに記載される名前
2. What is your email address used for logging into the Appcelerator Network?
 Appcelerator Networkに登録されているメールアドレス
3. What would you like as your default locale?
 言語ロケール
4. What Titanium SDK would you like to use by default?
 デフォルトで使用するTitaniumのSDKのバージョン
5. Path to your workspace where your projects should be created:
 プロジェクトを入れるワークスペースのパス
6. Path to the Android SDK:
 AndroidSDKのパス
です。

プロジェクトを作成するには、 titanium create とタイプします。

$ titanium create
Titanium Command-Line Interface, CLI version 3.0.18, Titanium SDK version 3.1.0.v20121121154400
Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.

Please report bugs to http://jira.appcelerator.org/

Target platforms: (android,ios,ipad,mobileweb) android
App ID: com.example.sample
Project name: sample

[INFO] Creating Titanium Mobile application project
[INFO] Project 'sample' created successfully in 34ms

途中聞かれる内容は
1. Target platforms: (android,ios,ipad,mobileweb) android
 ターゲットになるプラットフォーム
2. App ID: com.example.sample
 ドメインの逆順 + プロジェクト名とか
3. Project name: sample
 この名前でプロジェクトフォルダが作成されます。
です。

$ titanium build -p android
Titanium Command-Line Interface, CLI version 3.0.18, Titanium SDK version 3.1.0.v20121121154400
Copyright (c) 2012, Appcelerator, Inc.  All Rights Reserved.

Please report bugs to http://jira.appcelerator.org/

[INFO] logfile = /home/kuroyanagi/Titanium_Studio_Workspace/sample/build.log
[DEBUG] /home/kuroyanagi/.titanium/mobilesdk/linux/3.1.0.v20121121154400/android/builder.py simulator sample /home/kuroyanagi/android-sdk-linux /home/kuroyanagi/Titanium_Studio_Workspace/sample com.example.sample 7 HVGA
[TRACE] app property, ti.ui.defaultunit : system
[INFO] Building sample for Android ... one moment
[INFO] Titanium SDK version: 3.1.0 (11/21/12 15:44 32f6284)
[DEBUG] Waiting for device to be ready ...
[TRACE] adb devices returned 0 devices/emulators

エミュレータが立ち上がって

この様な画面が表示されます。