CBLDatabase not creating in iPad

When I am creating CBLDatabase using below code

CBLDatabaseConfiguration* config = [[CBLDatabaseConfiguration alloc] init];
[config setDirectory:[[NSBundle mainBundle] resourcePath]];
CBLDatabase *db = [[CBLDatabase alloc] initWithName:@“test_DB” config:config error:&error];
NSLog(@“%@”,db);

db is nil when I am running the code in iPad,

getting error
Error Domain=NSPOSIXErrorDomain Code=1 “Operation not permitted” UserInfo={NSLocalizedDescription=Operation not permitted}

but When I am running into simulator it’s working fine.

Using below code
CBLDatabase *dbNew= [[CBLDatabase alloc] initWithName:@“test_DB” error:&error];
it’s working fine in both place without any issue.

OS Version : 15.7.1

Looks like you are writing to application bundle, which is causing the issue. Could you try open a database inside application/cache/temp directory?

1 Like

Hi @jayahari.vavachan

1- When I am using this
CBLDatabase *db [[CBLDatabase alloc] initWithName:@“test_DB” error:&error];
its working fine

2- When I am using

CBLDatabaseConfiguration* config = [[CBLDatabaseConfiguration alloc] init];
[config setDirectory:[[NSBundle mainBundle] resourcePath]];
CBLDatabase *db = [[CBLDatabase alloc] initWithName:@“test_DB” config:config error:&error];

getting below error :
CouchbaseLite Database ERROR: SQLite error (code 14): cannot open file at line 39555 of [0c1fcf4711]
CouchbaseLite Database ERROR: SQLite error (code 14): os_unix.c:39555: (0) open(/private/var/containers/Bundle/Application/18987D18-FE35-4027-B5C9-789D1404B41F/PruOneExpress.app/test_DB.cblite2/db.sqlite3-wal) -
CouchbaseLite Database ERROR: SQLite error (code 14): statement aborts at 1: [PRAGMA user_version] unable to open database file
CouchbaseLite Database ERROR: unable to open database file (14/14)

I am setting application main bundle path for database creation

This is still the same issue that was mentioned before. You are trying to write to a read only directory.