Once you've found a module you wish to use in your mobile project, you'll need to install it such that you can use it inside Studio.
Go to http://marketplace.appcelerator.com to find the most complete list of available modules.
Once you have selected and purchased the modules you are interested in using, you'll need to download them.
- In marketplace.appcelerator.com, click on My Products.
- Click on the module you wish to download. It should download a .zip file to your computer. You may need to click on the little gear icon to find the download link the first time you download a module.
- Locate the .zip file on disk.
Modules can be installed one of two ways--per-project, or globally.
- Open Studio.
- Expand the project folder in the Project Explorer view.
- Drag the .zip file from the download location into the current project, placing it at the root of the project. Choose to "Copy Files".
- Locate your Titanium SDK installation location. For help, see Installing Titanium SDK Continuous Builds for the default location of the SDK folder.
- Drag the .zip file under the /Titanium folder. As an example, on OS X, the path might look like "/Library/Application Support/Titanium/module.zip".
Using Your Module
To use your module in a mobile app, follow these steps:
Using the tiapp.xml Editor
Studio has a module section inside the tiapp.xml editor to greatly simplify the usage of modules. In order to use the module editor:
- Double-click on the tiapp.xml file
- In the right-hand column, click the + to add a new module. It will show you a list of modules available in your global directory and in your project.
- Once you've added a module, clicking the pencil (edit) icon allows you to switch versions if there are multiple version available.
- If you wish to delete a module, click the x (delete) button to delete the module.
Switching a SDK will re-validate the modules based on their compatibility with the selected SDK. If they are not compatible, they will show warnings as appropriate, allowing you to update as appropriate.
Open the module's .zip file, and look at the folder structure. The path will look like the following:
- Open Studio, and the tiapp.xml file for the project in question.
- Switch to the tiapp.xml tab.
In the application's tiapp.xml, find the <modules/> node, and replace it with the new <modules> content. If you already have modules, just add a new node for the new module. Note that the "version" and "platform" attributes are optional. When "version" is not specified, the latest version of the module will be used (as of Titanium SDK 2.0.0), and the "platform" tag is only necessary when using a module that is not available on both platforms.
Use the require function to load the module in the app's code, for example:
- The next time the app is launched or built, the module should be included with the application.