0 Flares 0 Flares ×Editor’s note: The most up-to-date version of this tutorial is available in our wiki titled, Configuring Apps to Use Modules. One of the amazing and powerful features of Titanium Mobile, is the ability to extend the platform using modules. These modules are written and compiled in the native language of the OS and allow for your app to use features and APIs not part of the Titanium Mobile core. How do you install these modules?
- First off, download the module you want to use, for this example we will be downloading the AdMob module for iOS. The module can be downloaded here.
- The module is downloaded as a zip file, so un-zip it if it hasn’t automatically been expanded. You should now have a folder called modules. Inside that folder there will be another folder called iphone. Inside the iphone folder there should be another folder called ti.admob.
- Navigate to your /Library/Application Support/Titanium/modules directory. (note that it is in the root Library, not the one based off of the users folder) If there is not an iphone folder already inside the modules folder, create it.
- Drag the ti.admob folder inside this iphone folder, and your done!
- In order to use a module in a Titanium Mobile project, you have to explicitly state the module(s) your app is using within the tiapp.xml file. In your tiapp.xml file you should find the following code near the end of the file… [gist id=1085942] You simply need to alter that to this: [gist id=1085943] It is important to include the correct version number. If you don’t know what version you have installed, just navigate back to the /Library/Application Support/Titanium/modules/iphone/ (again, note the root Library) folder and inside the ti.admob directory you should see another folder with a version number. Include this version number in your code.
- The next step is the use of the module in your app, to do so we simply need to require (not Ti.include) the module with the following code: [gist id=1085947]
- And finally its time to use the module: [gist id=1085950]