How to use prebuilt CBLite2 on iOS


#1

I’m trying to use prebuilt cblite2 in my app.
I have got the cblite2 file added to my app bundle and use the method to copy it when app launch.

  • (BOOL) replaceDatabaseNamed: (NSString*)databaseName
    withDatabaseDir: (NSString*)databaseDir
    error: (NSError**)outError;

When I try to check exist or read the DB there is warning message:
“WARNING: CBLDatabase: Database version (101) is newer than I know how to work with”

[cbl_manager existingDatabaseNamed:dbName error: &error] will return nil

The CBLite framework version that I’m using are 1.1()
Any help will be much appreciate.

----------How I generate prebuilt cblite2

NSArray *tempArray = [NSJSONSerialization JSONObjectWithData:objectData
options:NSJSONReadingMutableContainers
error:&jsonError];

NSError *error;
NSString *s_db= dbName;

if (![CBLManager isValidDatabaseName:s_db]) {
    NSLog (@"Database %@ exist",s_db);
}
else {
    CBLDatabase *cbl_database=[cbl_manager databaseNamed:s_db error:&error];
    if (!cbl_database) {
        NSLog (@"Cannot create database %@. Error message: %@",s_db,error.localizedDescription);
    }
    
    for (NSDictionary *json in tempArray) {
        CBLDocument *doc=[cbl_database createDocument];
        CBLRevision *newRevision = [doc putProperties:json error: &error];
        if (!newRevision) {
            NSLog (@"Cannot write document to database. Error message: %@", error.localizedDescription);
        }
    }
}

----------How I try to copy

NSError error;
CBLDatabase
database = [cbl_manager existingDatabaseNamed:dbName error: &error];
if (!database) {
NSString* cannedDbPath = [[NSBundle mainBundle] pathForResource: dbName
ofType: @“cblite2”];

    BOOL ok = [cbl_manager replaceDatabaseNamed:dbName
                      withDatabaseDir:cannedDbPath
                                error:&error];
    
    if (!ok) {
        NSLog(@"Copy cblite failed: %@", error.localizedDescription);
    }
    
    database = [cbl_manager existingDatabaseNamed:dbName error: &error];
    
    if (!ok) {
        NSLog(@"Copy cblite failed: %@", error.localizedDescription);
    }
}

#2

That message comes from the 1.0.4 version. There are no released versions of 1.1 that consider 101 to be a new version. Did you recently upgrade your application from 1.0.4?


#3

Hi borrrden,

Do you mean the message come from CouchBaseLite.framework version 1.0.4?
But I check the plist in the framework it show bundle version 1.1().

I didn’t perform any update on CouchBaseLite.framework in my app.


#4

Yes, I mean this one

WARNING: CBLDatabase: Database version (101) is newer than I know how to work with

It used to be >= 100 but it has been >= 200 since 2015/04/28 and the first developer preview was released on 2015/05/02 with subsequent official releases on or around 2015/06/12 and 2015/09/15.

That version shows exactly like this -> 1.1() ?

That doesn’t sound like an official version (did you download it from the Couchbase downloads page). The latest version of 1.1 should show 1.1.1 (18) as in the below image

And the official version of 1.1.0 should be 1.1.0 (31).


#5

Hi borrrden,

As the couchbase was implemented by other developer before me so I had no idea where it was from.

So you suggest me to try update the couchbaselite framework?
Will there be any impact if I try to update the couchbaselite framework? As there is already app that was using current version running.


#6

We strive to minimize the impact of upgrading the framework, and I will always encourage you to use the latest version since we make a tremendous amount of improvements in each release. That being said, I also urge you to exercise caution and test out the upgrade first in a development environment (this may seem obvious but I’ve seen other people mess up their production environments by not doing this). I bet the developer before you compiled Couchbase Lite from source, which means that this could be any state between 2014/05/07 and 2015/10/20, possibly even with custom changes.

You will be better off with an official version, I think. Furthermore there is not much we can do to help you if you don’t know where the version of your framework came from.