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);
}
}