Trying to build a Cocoapod for iOS and Couchbase Lite

Has anyone managed to build a Cocoapod with a dependency on Couchbase Lite? I’m hitting problems like ‘target has transitive dependencies that include static binaries’. I’m adding the following line to the podspec

s.dependency 'couchbase-lite-ios', '~> 1.1'

I’ve successfully (a) added Couchbase to a project using a pod, and (b) built a pod with standalone code. The trouble is trying to build a pod with code that refers to Couchbase.

Maybe it can’t be done - I’ve see posts on the Cocoapod forums about serious voodoo needed to get some other frameworks to be included in pods.

Have you seen this github issue?

Also, there is work in progress for Carthage support:

Thanks for the comment @traun

I do use Couchbase Lite as a CocoaPod. That works nicely. What I want to do is to have my own functionality, wrapping CB things that every app needs, as a CocoaPod. That’s proving difficult.

Looking at Carthage is on my list. I like the idea that it’s simpler to set up than CocoaPods.

1 Like

I’ve been trying to do something similar (see this thread Using CouchbaseLite inside a custom Framework / iOS8). Trying to use CBL in a swift custom framework for example but I haven’t managed to make it work. Are you using cocoapods with swift or objc? The framework would be called something like CBL utils to be used across several projects. A first step would be to get it to work without cocoapods I think. Have you manage to do that?


Hi @jamiltz

Yes, we’re trying to do the same thing. I’m using Cocoapods with Swift, and yes the intention is a framework to be used across several projects.

I can build a Swift Cocoapod of standalone code. I can use the Couchbase Cocoapod.

Are we sure it’s possible? I’m sure you’ve seen all the same StackOverflow and CocoaPod threads I’ve been reading on transitive dependencies and so on.

I just found this blog which helped to understand how to access ObjC that resides in a cocoa touch framework.

I followed the steps:

  1. Create a new Xcode workspace
  2. Create a new Cocoa Touch Framework called CouchbaseUtils
  3. Download Couchbase Lite iOS and drag CouchbaseLite.framework in the Xcode framework
  4. Drag all the headers in the public headers section in build settings like so:
  5. Add the following line in CouchbaseUtils.h to make the Couchbase Lite API accessible:
#import <CouchbaseUtils/CouchbaseLite.h>
  1. Create a new single view application in the same workspace
  2. In Link binary with libraries, add CouchbaseUtils.framework
  3. Import the Couchbase Utils framework in swift classes
import CouchbaseUtils

Now, you should be able to use this CouchbaseUtils framework in other projects. Here, Couchbase Lite isn’t a pod which means that you will have to re-import it when a new version is available. It would be great to make it work with cocoapods so we’d only change the podfile to pull the new version.

An example workspace can be found here


I just tried it again and it doesn’t actually work.

Class in Xcode project:

import CouchbaseUtils

class ViewController: UIViewController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib
        let _ = CBLManager.sharedInstance()

Error message in Xcode:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_CBLManager", referenced from:
      objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Using CBL in a framework should be possible in 2.0 though (see Installing Couchbase Lite with Cocoapods in a framework)