Use CouchbaseLiteSwift with Cocoapods

I’ve been including pre-built CouchbaseLiteSwift module in my project, but it’s always a pain when we upgrade Xcode as the Swift minor version changes. Now with Xcode 10 it gives me some more weird errors like it cannot build the Objective-C module for CBL. So is it possible to include CBL with Cocoapods instead of as prebuilt module??

I tried

pod ‘couchbase-lite-ios’

but it only installs 1.4.1. If I speicify

pod ‘couchbase-lite-ios’, ‘~> 2.1’

pod install would complain that it cannot find the repo.

Just wondering if Couch still supports pod installation in 2.0.

You can point your podfile to couchbase-lite-ios repo directly and when you do pod update, we have written a step in the podspec to run xcodebuild to build the framework and link to the app (not linking with the source code directly). However it could take some time (e.g. 30+ mins) to build the framework as cocoapods will build the framework for all platforms.

pod 'CouchbaseLite-Swift', :git => '', :tag => '2.1.0'
1 Like

Also the pod names for Couchbase Lite 2.0 are “CouchbaseLite” (for Objective-C) and “CouchbaseLite-Swift” (for Swift). Without specifying the git repository, the prebuilt binaries will be downloaded.

The prebuilt binaries would have the Swift version compatibility issue in newer Xcode (Xcode 10, Swift 4.2), right?

got the error with pod install

Pre-downloading: CouchbaseLite-Swift from, tag 2.1.0
[!] Failed to download ‘CouchbaseLite-Swift’.

Downloading the prebuilt lib is successful, but it was compiled in 4.1 so it doesn’t work with Xcode 10.

If specifying the git location, the framework will be built using the local XCode when running pod update. It’s not an ideal for the case that there is a new version of XCode coming and the same version of the CBL framework needs to be built again (probably need to delete Cocoapods’s cache).

Sorry, the github URL is not correct. Please try below:

pod ‘CouchbaseLite-Swift’, :git => ‘’, :tag => ‘2.1.0’

Umm … There seems to be an issue. I’m looking at it now; will post the update here.

1 Like

Try this instead:

pod ‘CouchbaseLite-Swift’, :git => ‘’, :tag => ‘2.1.0’, :submodules => true

1 Like

this looks it’s working and it looks like I have to delete the couchbase folder from Pods on Xcode (I downloaded the 4.1.2 binaries a couple of hours ago), then pod update is actually taking some time as it is still working on it…

it’s very weird, even with pod 'CouchbaseLite-Swift', :git => '', :tag => '2.1.0', :submodules => true it’s still complaining about the framework was compiled in 4.1.2

I suspect this pod command still downloads the prebuilt CBL modules instead of building from the source code, due to two observations: 1. there is no delay at all when doing pod install, 2. the Xcode 10 build still failed with “cannot use modules built in swift version 4.1.2 for swift 4.2”

I then tried the locally built CBL module 2.1.0 from the couchbase-lite-ios repo, but putting it inside a brand new skeleton test project created in Xcode 10 gives me build errors “Header CBLArray.h not found” and “Could not build Objective-C module ‘CouchbaseLiteSwift’”, exactly as what I saw with our main project when including the locally prebuilt modules (not via cocoapods).

Has anyone at Couch tried building a sample project with CBL in Xcode 10 GM Seed?

@pasin Now Xcode 10 official release is out but I’m still having the above problem with “Header CBLArray.h not found” in both my main project and a simple test project. Do you have any update on your experience of using CBL 2.1.0 in any project with Xcode 10 on your side?

Just in case anyone else have similar issue, this is due to an issue in CBL 2.1.0 and earlier versions. The new version CBL 2.1.1 that is just released solved this issue.