Every now and then, you need to use an external module in your app to access things that don’t exist in the native Titanium SDK like a barcode scanner (Ti.Barcode, Ti.Codescanner). Many of these plug-ins are open source and can be found here at the modules page or on GitHub.
In order to use those modules you have to download the binary/zip first. There are multiple ways to get the file:
Github: release tab
The first place to look is at the “Release” tab:
If you see a number next to “releases,” there are multiple binaries uploaded in the repository. For Ti.Barcode, you can see all the releases for iOS and Android: https://github.com/tidev/ti.barcode/releases
You just search for the latest for your OS and download the binary ZIP (not the source!) and place it in your project folder.
Github: dist folder
If you can’t find anything in the release tab, the next place to look is the distribution folder of the module. When you compile a module, it will be placed in a folder called “dist/”. You can find this under “module/android/dist” or “module/ios/dist”. For example, the push module Ti.Goosh by Caffeina (https://github.com/caffeinalab/ti.goosh) is using that folder: https://github.com/caffeinalab/ti.goosh/tree/master/android/dist
Again, you download the ZIP file and place it into your project.
Github: pull requests or fork
The last place to look is the “Pull request (PR)” menu or the module forks. During the update from Titanium SDK 6 to 7, you needed to update your Android modules. Some module owners aren’t active anymore or don’t have time to update these modules themselves. Luckily, some Appcelerator users fork those modules and create compatible versions or even add new features. When the repository is not active anymore, those updates won’t be included in the official page, but you still can use those new modules.
A module for Android called Ti-Android-CameraView by Michael Browne (https://github.com/brownemint/Ti-Android-CameraView) is currently not available for Titanium SDK 7. But, there is a PR that adds compatibility and some bug fixes inside the PR section: https://github.com/brownemint/Ti-Android-CameraView/pulls
If you click on this PR, you will see a list of the changes and a tab with “Files changed”. There you will get a whole list of files, and you search for a new file in the dist folder. In this PR, it is called “dist/pw.custom.androidcamera-android-1.0.1.zip”. You can click the “View” button on the right side and download the ZIP from there.
Another way to get to the file is to have a look at the forks. To do this, you need to click on “Insights – Network” and you will get a graph with all forks. Most of the time, it is the latest in the graph and you can click on that dot to go to the repository:
Compile it yourself
If you can’t find any binary inside the repository, you have to compile the module yourself or ask at TiSlack if someone can help out. To compile the module, you can clone the repository with
git clone https://github…./module-name
and then look at the official guides at https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Extending_Titanium_Mobile/ for how to compile modules. If you have everything setup correctly, it is most of the time just a simple
ti build -p ios --build-only
ti build -p android --build-only
The binary will be inside the “dist/” folder.
Use the module in your app
Now that you have a ZIP file of the module you want to use it in your app. To do this you simply place the ZIP file in your project root folder and add it to the tiapp.xml file. You extend the
<modules></modules> part with your module like this:
<modules> <module>ti.map</module> </modules>
After that you can build your app. It will extract the ZIP file and place it in the right folder (
/modules/ios) and the module is ready to be used now.