Skip to content

Building Couchbase Lite

Jens Alfke edited this page Aug 25, 2018 · 17 revisions

NOTE: This document applies to Couchbase Lite 2. If you're still using the older 1.x versions, see Building Couchbase Lite 1.x.

Why Build Couchbase Lite?

We prefer that developers use the builds of Couchbase Lite provided by Couchbase, which you can download directly, or via Carthage or CocoaPods as described in the README.

However, you may want to build from source, for reasons like:

  • You want to test a recent bug-fix that's been checked in but not yet released
  • You want to try out bleeding-edge unreleased features
  • You want to contribute to development
  • You're working with a beta release of Xcode that includes a newer version of the Swift compiler -- in this case you will not be able to link the released Couchbase Lite framework into your app, because it was built with a different version of Swift. (Swift is not yet "ABI-stable", which means binaries generated by different compiler versions are not yet interoperable. This is expected to be the case until Swift 5.)

EE vs CE

The source code publicly available on Github will build the Community Edition (CE) of Couchbase Lite. This version is completely open source, and you can do whatever you like with it subject only to the liberal terms of the Apache 2 license.

However, if you're a customer of Couchbase you are likely using the Enterprise Edition (EE), which contains some additional features (such as database encryption). It is not possible to build your own Enterprise Edition, since it includes some closed-source code that we distribute only in binary form.

If you still need to build Couchbase Lite from source for development purposes, you'll run into compile or link errors at the places where your code calls the EE-only APIs. You can work around this by commenting out that code. Obviously this isn't viable for releasing your app, but it will let you temporarily test a bug-fix or develop with a beta Xcode.

How To Build It

  1. Clone the repo, check out the appropriate release branch (or the master branch for bleeding-edge stuff), and update submodules
$ git clone https://github.com/couchbase/couchbase-lite-ios.git
$ cd couchbase-lite-ios
$ git checkout release/2.1   # or whatever release you want, or 'master' for the latest commits
$ git submodule update --init --recursive
  1. Run ./Scripts/build_framework.sh to build a framework for Objective-C or Swift. The supported platforms include iOS, tvOS, and macOS.
$ ./Scripts/build_framework.sh -s "CBL ObjC" -p iOS -o outputDir    // For building the ObjC framework for iOS
$ ./Scripts/build_framework.sh -s "CBL Swift" -p iOS -o outputDir   // For building the Swift framework for iOS

The resulting framework will be located in the directory outputDir (or whatever path you put after the -o flag.)