This is the super task (specific iOS and Android sub-tasks exist).
For example, when create either an iOS or Android module project, you get the .m and .java files for the module and a method named example. If you also add a commonjs module file in the form of assets/[moduleid].js, then that example method inside the native source file is not reachable at runtime when the module is used.
We wish to make the optional CommonJS module file "additive" in the sense that it extends whatever is available via the native source, rather than replaces it.
- Create a module project for the platform you're testing (iOS or Android).
- Create a file assets/moduleid.js (replace moduleid with the actual module id) and enter this code:
- Build/package the module (./build.py for iOS, ant for Android.)
- Create a Titanium Mobile app.
- Install the module zip to the app (or up in the Titanium root). No instructions here – it's assumed you know how to install a module.
- Update tiapp.xml to include the module. (assuming you know how).
- Put this in app.js:
- In the console/logcat, you should see info statements for "hello from inside the module's commonjs file" and "hello world".