iOS Core Data and Couchbase integration

162 views
Skip to first unread message

bjoe...@gmail.com

unread,
Dec 6, 2013, 9:09:55 AM12/6/13
to mobile-c...@googlegroups.com

Hello,

i'm new to iOS-Development and i'm currently evaluating the Couchbase ecosystem for the use with an existing iOS app that uses Core Data in combination with a SQLite database.As far as i have read and understood Couchbase Lite doesn't support integration with existing apps that use Core Data for the persistence layer yet. Rewriting the app is no solution for us but in this thread theres a pointer to a project, which, as i understand, makes it possible to adapt Core Data based apps to sync with Couchbase server. Do you think that this is a viable solution? Any help, hints, suggestions or pointers to the right direction would be great!

Thanks in advance
Bjoernfe

J. Chris Anderson

unread,
Dec 6, 2013, 4:24:12 PM12/6/13
to mobile-c...@googlegroups.com
Hi Bjoernfe, we are working on something that is in progress but potentially useable, based on the thread you mention. You are welcome to jump in although things are a little rough at the moment. Our goal is to get this cleaned up and merged in the next few weeks: https://github.com/couchbase/couchbase-lite-ios/pull/214

Alan McKean

unread,
Feb 9, 2014, 2:17:47 PM2/9/14
to mobile-c...@googlegroups.com
What is the status of this? Is it a custom NSAtomicStore?

Jens Alfke

unread,
Feb 9, 2014, 2:33:43 PM2/9/14
to mobile-c...@googlegroups.com
On Feb 9, 2014, at 11:17 AM, Alan McKean <alanm...@me.com> wrote:

What is the status of this?

It's been checked in since beta 2, although we didn't include it in the binary release. If you want to use it, clone the Couchbase Lite repository, check out the 'stable' branch, and copy Source/API/Extras/CBLIncrementalStore.* into your project.

Right now I believe the only documentation is what's in the doc-comments in the header file.

Is it a custom NSAtomicStore?

No, it's an NSIncrementalStore.

—Jens

Jens Alfke

unread,
Feb 10, 2014, 11:25:50 AM2/10/14
to mobile-c...@googlegroups.com

On Feb 9, 2014, at 11:33 AM, Jens Alfke <je...@couchbase.com> wrote:

It's been checked in since beta 2, although we didn't include it in the binary release. If you want to use it, clone the Couchbase Lite repository, check out the 'stable' branch, and copy Source/API/Extras/CBLIncrementalStore.* into your project.

I just looked at the git history, and the above is not quite correct:
  • CBLIncrementalStore was merged in just after beta 2.
  • The best commit to check out to get the latest source for it is 5f7c6ee — you can copy the CBLIncrementalStore.* sources from there into your project, but keep using the beta 2 release of Couchbase Lite.

—Jens

Alan McKean

unread,
Feb 10, 2014, 2:23:18 PM2/10/14
to mobile-c...@googlegroups.com
Thanks. I did as you suggested and incorporated the CBLIncrementalStore. Created a managed object context with ccreateManagedObjectContext:withModel:databaseName:importingDatabaseAtURL:importType:error:. added an observer with addObservingManageObjectCOntext:, etc.  So far have been unable to get any of the CBL data to show up in my table views. Still tinkering.

Christian Beer

unread,
Feb 11, 2014, 9:47:16 AM2/11/14
to mobile-c...@googlegroups.com
The CBLIncrementalStore depends on some fields in the CBL data for mapping between the CBL data and the Core Data entities. If you're working with an existing CBL database those fields may be missing (especially CBLIS_type). But if I understand your post correctly, you're trying to import an existing SQLite database.

Did the createManagedObjectContext:...importinDatabaseAtURL:... method return a context? Did you try to execute some NSFetchRequests on it, to see if there is some data?

I am the guy who wrote the CBLIncrementalStore and I'm glad there's at least somebody who uses it (or tries to). So I hope I can help.

Cheers,
Christian

Alan McKean

unread,
Feb 12, 2014, 7:30:32 PM2/12/14
to mobile-c...@googlegroups.com
Sorry it took me so long to get back. Between jury duty and getting heads down in code, the time slipped by. I abandoned the Core Data/CBL integration and have been converting the app to a pure CBL version. It seems to be coming along fine. Not having to convert/store between the documents and the Core Data rows eliminates a lot of code and solves most of my offline strategy problems.
Reply all
Reply to author
Forward
0 new messages