Skip to content
pegli edited this page Aug 31, 2012 · 22 revisions

To learn more about TouchDB, the underlying implementation of this module, see the TouchDB-iOS Wiki. See the Building page for information on how to build the module from source.

iOS Usage

TiTouchDB will only run on iOS 5.0 or later. By default, Titanium applications are configured with a minimum required OS version of 4.0. With earlier versions of the Titanium SDK, you could open the generated Xcode project file and change the deployment target version to 5.0, but more recent (2.1.x) versions of the SDK, that file gets overwritten on each build. There is an open bug that promises a fix for this soon. In the meantime, you will need to edit the project file templates in your SDK directory to do the following:

  • change all instances of IPHONEOS_DEPLOYMENT_TARGET = 4.0; to IPHONEOS_DEPLOYMENT_TARGET = 5.0;
  • remove all references to armv6

The file templates are:

iphone/iphone/Titanium.xcodeproj/project.pbxproj
module/iphone/templates/___PROJECTNAME___.xcodeproj/project.pbxproj

IMPORTANT NOTE: obviously, this will affect all the projects you build with the modified SDK. You might consider copying your current SDK file and modifying the copy.

Once you have the minimum SDK set, copy the module ZIP file to either the project root directory (the same directory as tiapp.xml) or your Titanium installation. Build your project to expand the module archive. Once that is done, you can edit tiapp.xml and add the module to the modules section:

<modules>
    <module version="0.4" platform="iphone">com.obscure.titouchdb</module>
</modules>

If you're using Titanium Studio, you can edit tiapp.xml and add the module from the fancy GUI.

Android usage

Copy the module ZIP file to either the project root directory (the same directory as tiapp.xml) or your Titanium installation. Build your project to expand the module archive. Edit tiapp.xml and add the module to the modules section:

<modules>
    <module version="0.4" platform="android">com.obscure.titouchdb</module>
</modules>

Loading the module

Here's how to load up the module and get a database object:

var server = require('com.obscure.titouchdb');
var db = server.databaseNamed('books');
db.ensureCreated();

See the API documentation, FAQ and TouchBooks sample for more information.

Clone this wiki locally