特徴
- JavaScriptでAndroid/iOSのネイティブアプリを作成できる
- Android/iOSのアプリを同じコードで開発可能
- 同じソースでもAndroid/iOSそれぞれ最適なUIになる
しくみ
-
JavaScriptで書かれたバイナリをTitanium エンジンが実行時に解釈して実行するしくみのよう
-
JavaScriptのコードはTitanium APIを呼び出して実装
-
JavaScriptエンジンは Titanium APIを解釈し、各プラットフォームのAPIを呼び出す
-
http://docs.appcelerator.com/titanium/latest/#!/guide/Titanium_Platform_Overview には、"Mobile applications built with the Titanium SDK are run against a standalone JavaScript engine which invokes native APIs." と ". The Titanium tools combine your JavaScript source code, a JavaScript interpreter, and your static assets into an application binary that will be installed to an emulator or mobile device." と書いてある。
-
applieの規約的にも問題がない模様 http://www.apple.com/pr/library/2010/09/09Statement-by-Apple-on-App-Store-Review-Guidelines.html => "In particular, we are relaxing all restrictions on the development tools used to create iOS apps, as long as the resulting apps do not download any code. This should give developers the flexibility they want, while preserving the security we need."
コード
- https://github.com/appcelerator/titanium_mobile
- Apacheライセンス
環境
- http://www.appcelerator.com/ からSDKをダウンロード(ユーザ登録が必要)
- Titanium StudioというEclipseベースのIDEをダウンロードすることになる
- Titanium Studioを通して、SDKやCLIツールをダウンロードする
Alloy
- https://github.com/appcelerator/alloy
- itanium 向けの MVC フレームワーク
ひな形
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
// open tab group
tabGroup.open();
API
モジュール
- Titaniumには、モジュールという機能があり、ネイティブの言語で作成した機能をモジュールとして、Titaniumで使用することができる
- できるJavaScriptで機能をまとめてモジュールとして提供することも可能
- 既存のモジュールはマーケットプレイスで入手可能(有料・無料あり)
- https://marketplace.appcelerator.com/home
- 例えば、Androidの in-app bilingなどは、 https://marketplace.appcelerator.com/apps/776?1472334983 が利用できる(無料)
- 他の開発者が作ったモジュールがGitHubで公開されていることも
モジュールの概要
モジュールのライセンス
- ライセンスに関しては言及されてないが… Apacheライセンスで混ぜるな危険ではない+元と組み込む必要がないので、自由にライセンスつけていいのではないか。
- https://github.com/laiso/titanium-hatenabookmark 見たいにMITライセンスとか別のライセンスで公開している
- マーケットプレイスで有償のモジュールはコードが公開されているわけではないので(コード公開したら有償にならない)、モジュールは公開しなくてもいいのかも