Creating a new project

When you begin writing a new app you need to incorporate Couchbase Lite into your project. This lesson shows you how to add Couchbase Lite and its other dependencies to a new project.

Create a new project


The following steps set up a new project with the file names used in this tutorial.

  1. Open Xcode and select File > New > Project.

  2. In the new project template sheet, click Empty Application and then click Next.

  3. In the new project options sheet, enter values for each field and then click Next. In this example, we will be using the sample app "HelloCBL" to illustrate how to create a new iOS project and add Couchbase Lite to it.

    Here are the values used in the sample app:

    • Product Name—HelloCBL
    • Organization Name—Couchbase
    • Company Identifier—com.couchbase
    • Bundle Identifier—com.couchbase.HelloCBL
    • Class Prefix—HC
    • Devices—iPhone
    • Use Core Data—no
  4. Select a location for your new project, and then click Create.

Add the Couchbase Lite framework


The framework provides the interfaces for writing apps with Couchbase Lite.

  1. Download the latest release of Couchbase Lite for iOS and move the unzipped Couchbase Lite folder to a permanent location.

  2. Open the Couchbase Lite folder and drag the CouchbaseLite.framework folder to the Frameworks group in the Xcode project navigator.

    Couchbase Lite framework file location
  3. In the Choose options for adding these files sheet, make sure that your app target is selected.

Add dependencies


Couchbase Lite requires additional frameworks and libraries for building an app. These additional dependencies are added via Xcode build settings.

  1. In the navigator, click on the HelloCBL project file to open the project editor for your app, and then click the Build Settings tab.

  2. Scroll to the Linking section, find the Other Linker Flags row, and then add the flag -ObjC (be sure to use the capitalization shown).

    The Other Linker Flags row should look similar to the following screenshot:

    build settings
  3. Click the Build Phases tab.

  4. Expand the Link Binary With Libraries section and add the following items:
    • CFNetwork.framework
    • Security.framework
    • SystemConfiguration.framework
    • libsqlite3.dylib
    • libz.dylib

    Click the + at the bottom of the section to add each item. When you are done, it should look similar to the following screenshot:

    build phases