Use CouchbaseLiteSwift with Cocoapods


#1

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.


#2

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 => 'https://github.com/couchbase/couchbase-lite-ios', :tag => '2.1.0'

#3

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.


#4

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


#5

got the error with pod install

Pre-downloading: CouchbaseLite-Swift from https://github.com/couchbase/couchbase-lite-ios, 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.


#6

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).


#7

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

pod ‘CouchbaseLite-Swift’, :git => ‘https://github.com/couchbase/couchbase-lite-ios.git’, :tag => ‘2.1.0’


#8

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


#9

Try this instead:

pod ‘CouchbaseLite-Swift’, :git => ‘https://github.com/couchbase/couchbase-lite-ios.git’, :tag => ‘2.1.0’, :submodules => true


#10

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…


#11

it’s very weird, even with pod 'CouchbaseLite-Swift', :git => 'https://github.com/couchbase/couchbase-lite-ios.git', :tag => '2.1.0', :submodules => true it’s still complaining about the framework was compiled in 4.1.2


#12

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?


#13

@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?