Using CouchbaseLite inside a custom Framework / iOS8

I’m trying to use CouchbaseLite inside a Swift custom Framework (under iOS8) but I have no visibility on CB classes.
I imported CouchbaseLite framework file inside my framework and added needed dependencies and settings.
Being a custom framework I can’t use a bridging header neither can add a #import to the umbrella header or my own Swift classes.
Is there a way to be able to use CB this way? (CouchbaseLite framework file inside a custom Framework)



Hi @esabhcuoC,

This looks similar to this question

I’m not sure how to import ObjC in a custom Framework.

@jens do you know if this is possible?


Why not? As far as I know, bridging headers are not specific to app targets.

Note that since Couchbase Lite is a static library (not a true dynamic framework) you don’t use import to access it. The classes will be in your namespace as though they were your own source files.

jens, bridging headers cannot be used inside Framework targets. So, we have no visibility from our framework to the CB Framework classes.
If you need a sample project (framework type project) I can send it to you so you can see exactly what’s the issue.

Hi @esabhcuoC,

Sorry for the late reply. Can you upload the sample project with the CouchbaseKit custom framework?
There’s an upload button in this forum you can use to attach it to your message for everyone to see.


Hi there, I cannot upload the file as the forum says "new users can’t upload files."
However, here you have a link to it so you can test it. As you will see, I’m unable to use the CB classes inside my class CouchbaseDB…


@esabhcuoC, Have you found the solution on this issue or do you need help?

i had faced issue like you, but now everything doing good.

@itssrinadh Yes! It would be great if you could share a sample project with that setup. I had tried to do it with a modulemap file as suggested in the gitter channel:

but couldn’t get it to compile.


@jamiltz am i right? he is unable to import Couchbase Lite Framework in Swift2.0, if it is the issue, i can upload one sample for him.

Yes but more specifically the question is about how to import Couchbase Lite in a Framework (called CouchbaseUtils for example) and then that framework could be reused across different Xcode projects.


@jamiltz sorry i haven’t tried like that.

Hi there. Any updates on this subject ? We are trying to include CouchbaseLite framework in a swift based CocoaTouch framework and running in this “include of non-modular header inside …” error.

Is the solution using a module.modulemap file working ?


I’m using CBL inside a Swift 2.x framework, and yes the key is to include a module file. Ours looks like:

module CouchbaseLite {        
     header "../Frameworks/CouchbaseLite.framework/Headers/CouchbaseLite.h"    
     export *     

Ensure your module file is in the correctly named directory, and the project settings are correct to have it import properly.

Also, when your framework is consumed, a module file is required in the consuming app as well.

1 Like

I’m using CouchbaseLite in a swift project as well. Here’s my bridging header:

Can you please provide more information on how did you accomplish that as I have already done so as I have answered How I have done.

What worked that Xcode will run and build successfully , but when I tried to run
Pod lint to complete the pod framework of it it will give errors on

- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include static binaries: (/private/var/folders/wr/lx9z4zts15nbqb9wxwsp2ryh0000gn/T/CocoaPods/Lint/Pods/couchbase-lite-ios/CouchbaseLite.framework and /private/var/folders/wr/lx9z4zts15nbqb9wxwsp2ryh0000gn/T/CocoaPods/Lint/Pods/couchbase-lite-ios/CouchbaseLiteListener.framework)