C4db_open with kC4DB_Create config option not working on iOS?

Hi,

I have a working example of couchbase-lite-core on Mac OS. When no database file or directory exists, if creates one.

C4DatabaseConfig defaultC4DbConfig = { kC4DB_SharedKeys | kC4DB_Create, kC4SQLiteStorageEngine, kC4RevisionTrees, { kC4EncryptionNone, {0}}};

QString path = QString("%1/database").arg(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first());

_c4Database = c4db_open(QSlString(path), &defaultC4DbConfig, &error);

if (_c4Database == nullptr)
{
    logC4Error("couldn't open database", error);        
    return;
}

The same code on iOS is not working:

2019-04-13 00:16:41.259171+0100 couchbase_qt[763:370301] "/var/mobile/Containers/Data/Application/CD3B94A9-F48E-40AD-9EB4-F919AADDC350/Library/Application Support/couchbase_qt/database"
2019-04-13 00:16:41.260927+0100 couchbase_qt[763:370301] couldn't open database: No such file or directory

Is there any expectable different behavior from the mac version?

Thanks!

Best regards,

Nuno

I have used Documents location instead of Data location and it is now working.

1 Like

Yeah, it looks like the parent directory of your path didn’t already exist.