App with Mobile CouchBase for iOS/iPad

Reading time ~1 minute

Update

The Mobile Couchbase team recently updated the project files and documentation to use MobileCouchbase in your own Apps. You can find the documentation on GitHub.

It took me two days to get the mobile CouchBase running in Xcode 4. So here’s how it works:

Important: Do not build or run the project until you have set it up completely!

  • Get the latest CouchBase repository from https://github.com/couchbaselabs/iOS-Couchbase/
  • Open Xcode
  • Create a new project. I used the Split View-based Application. Make sure "Use Core Data" and the initialization of the git repository is checked.
  • Add CFNetwork.framework from the iOS system frameworks and the DatabaseManager.h / DatabaseManager.m to your project in Xcode.
  • #import "DatabaseManager.h" in your application delegate
  • Now it get's a bit tricky. You need to get the source code for three libraries. Open your development root folder and type the following commands:
    git submodule add git@github.com:TouchCode/TouchJSON.git /Vendor/TouchJSON
    git submodule add https://github.com/schwa/trundle.git /Vendor/trundle
    git submodule add https://github.com/TouchCode/TouchFoundation.git /Vendor/TouchFoundation
  • Open the Finder and locate the "Source" directories for each library and copy the directory into Xcode (ONLY the directory within these library called "Source". You can rename them in the Xcode browser according to their library-names after copying them. Make sure "Copy items into destination group's folder" is checked, and "Create groups for any added folders" is active).

Build succeeded. :)

Update

I forgot to implement "Couchbase.h", and after putting #import "Couchbase.h" into the Delegate, the whole thing didn't compile anymore.

The solution is as following: Create a folder and include your project and the Couchbase-folder. Now create a Workspace and copy your project file (xcodeproj) and the Couchbase.xcodeproj into the workspace in Xcode. Copy the “Couchbase.h” into the Libraries-folder of your project and it should compile. From this point you can start creating your CouchBase app.

I had a lot of problems with linker errors complaining about i386 and armv7 missing links etc. Make sure you have the right schema (iPad simulator) and the right valid architectures “armv6 armv7”. Cleaning the project doesn’t always help in this case, so find your “DerivedData”-folder (usually ~/Library/Developer/Xcode/DerivedData) and delete the entire project folder. Then rebuild the project again.

Europe on Two Wheels

![Iron 883](/images/2015/07/IMG_7368.jpg)## Barcelona (Spain) - Le Dramont, Cote d'Azur (France)> 648km![Le Dramont](/images/2015/07/IMG_...… Continue reading

Updates!

Published on September 10, 2014

HTML5 vs. Native [thoughts]

Published on February 26, 2014