Appcelerator Blog

The Leading Resource for All Things Mobile

Building apps with modules

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?
  1. 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.
  2. 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.
  3. 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.
  4. Drag the ti.admob folder inside this iphone folder, and your done!
How do you use the modules?
  1. 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.
  2. 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]
  3. And finally its time to use the module: [gist id=1085950]
It might look like a lot of work at first, but once you get the hang of it its rather easy. In this repo (in the admob directory) we have a sample app that makes use of the admob module for you to import into Titanium Studio and examine for your own use. While the code is all there, you will still need to install the module itself using the first set of instruction, but this will provide you with code that you know to be functional as long as the module is installed.
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×


  1. jam

    Great, but do you plan to update this module with lastest admob sdk?? “Google”, not admob anymore, updated it a few weeksss ago ! :/

  2. Patrick McLean

    Hi, great post. I’ve been looking for adSense or the mobile adSense SDK support in Ti. I’ve found some old posts with different implementations – perhaps I haven’t looked in the right places. This strikes me as a good way to wrap the GoogleAdSense Mobile APK for use in Ti. Any thoughts?

  3. SkrabakL

    Hi, will the OpenGL/Box2D be available later on android device too ?

  4. Nice post, Matt. (I’ve read slightly different advice on this in the Community Forum, so just trying to be sure). For example, one green/accepted post had stated to simply put the unzipped file in the folder. Also, not clear if the version number subfolder should still be left in or not. One thing that some folks might miss is that I understand this is the ‘root’ library folder and not the one under the username. Thanks.

  5. Matt Apperson

    @brian, This way is correct, and the version number sub-folder is what contains the module code so it is 100% required. Yes this should be in the root library ( I have updated the post to indicate this).

  6. Dharmesh

    Just wondering but what params can we specify in terms of placement. I see top: 0 but when I try bottom:0 nothing seems to work, the ad is always placed at the very top.

  7. ivan

    I tried with the example I downloaded from github,
    it works with the publisherid in the example , but dose don’t work with my publisherId.
    someone can help me?

Comments are closed.

Sign up for updates!

Become a mobile leader. Take the first step to scale mobile innovation throughout your enterprise.
Get in touch
computer and tablet showing Appcelerator software
Start free, grow from there.
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×