Titanium Tips

Modules - Testing

Paint module working correctly
In this previous post, I explained how to install a module for Titanium Mobile. Now I will try to explain how to actually make that module work.

1. Ensure that your module is installed correctly. Follow this post for instructions if need be.

2. In order to use a module in a Titanium Mobile project, you have to alter the tiapp.xml file for that project. This means that you have to explicitly decide which of your apps will use a module. This is actually a good thing, as it ensures that no extraneous files will be included in your finished app. If you don’t wish to use any modules, just leave your tiapp.xml file as is. If you do want to use a module in a project, navigate to your app’s folder and open the tiapp.xml file.

3. By default, your tiapp.xml file should include the following code near the end...

If you want to use the Paint module, for example, change the code so it looks like...
        <module version="1.0">ti.paint</module>
ti.paint is the name of the folder that we installed in this previous tutorial. If you have installed a different module, use the corresponding name.

It is important to include the correct version number. If you don’t have a clue what version you have installed, just navigate back to the /Library/Application Support/Titanium/modules/iphone/[Module Name] folder and you should see another folder with a version number. Include this version number in your code.

4. Open Titanium Developer and launch the iPhone Simulator to test your app. If you have installed the module correctly and updated your tiapp.xml file correctly, you should see a message like that shown below, saying “Detected third-party module: [Module Name]/[Module Version]”.


5. You can now use the module as per the documentation, which you will find in the /Library/Application Support/Titanium/modules/iphone/[Module Name]/[Module Version]. Often this requires you to add a statement such as...
var paint = require("ti.paint");

...before adding an extra function like...
var paintview = paint.createView({

6. That’s it. Go and experiment!