2014年3月3日 星期一

Ti Module Development for iOS

Legacy Command Line Interface
http://docs.appcelerator.com/titanium/latest/#!/guide/Legacy_Command-Line_Interface

Steps to create iOS Module:
http://docs.appcelerator.com/titanium/latest/#!/guide/iOS_Module_Development_Guide-section-29004946_iOSModuleDevelopmentGuide-Step2%3ACreatingyourFirstModule


                                                                 
Step 1: create Module
> titanium.py create --platform=iphone --type=module --dir=./tmp/ --name=test --id=com.example.test
Step 2:
open created xcode project and build. You may need to modify the titanium.xcconfig to point to the correct path.

Step 3: package the module
> ./build.py

Step 4: Test run
> titanium.py run
It will launch iOS Siumulator automatically.

Step 5: install Module before testing in application
> cp com.example.test-iphone-0.1.zip /Library/Application\ Support/Titanium/
Step 6:  Add to your Titnaium Application.

Include module in tiapp.xml

   version="0.1">com.example.test
Add code to to use module:
var test = require('com.example.test');
Ti.API.info("module is => "+test);
                                                                

Module Architecture

- Module can only have one module class but can have zero/more Proxies, Views and ViewProxies


- The ViewProxy represents the model data (which is kept inside the proxy itself in case the View needs to be released) and is responsible for exposing the APIs and events that the View supports.
- You create a Proxy when you want to return non-visual data between JavaScript and native. The Proxy knows how to handle any method and property dispatching and event firing.


Module Lifecycle

load ( This allows the application to register callbacks for lifespan events, such as application:didFinishLaunchingWithOptions.)
startup 
shutdown 

For items you want to inject right into the runtime, use the performSelectorDuringRunLoopStart method to assign a callback that executes every time a run loop starts before the file is executed. The selector is a class method that takes one argument, which is the TiBindingRunLoop method. This is useful for modifying the runtime or for debugging by capturing exceptions before the application has been parsed.

More detail here: http://docs.appcelerator.com/titanium/3.0/#!/guide/iOS_Module_Development_Guide

Tutorial with sample project

http://www.appcelerator.com/blog/2011/10/module-development-guide-reference-module-for-ios-and-android/

Sample Code

http://www.appcelerator.com/blog/2011/03/tiplus-modules-starter-pack/

Tutorial in Slideshow
http://www.slideshare.net/omorandi/ticonf

Advanced Tricks For iOS Modules In Appcelerator Titanium
http://www.itexico.com/blog/bid/100221/Mobile-App-Development-Advanced-Tricks-For-iOS-Modules-In-Appcelerator-Titanium

沒有留言:

張貼留言