Question

I'm attempting to add SQLCipher to an iOS project that is using Magical Record library in order to encrypt a database. Also using the EncryptedStore class from encrypted-core-data project: https://github.com/project-imas/encrypted-core-data.

Having followed the instructions in post iOS Magical Record & SQLCipher

I've edited method - (NSPersistentStore *) MR_addSqliteStoreNamed:(id)storeFileName withOptions:(__autoreleasing NSDictionary *)options to be..

[coordinator
                                    addPersistentStoreWithType:EncryptedStoreType
                                    configuration:nil
                                    URL:databaseURL
                                    options:options
                                    error:&error];

with options:

NSDictionary *options = @{
                            EncryptedStorePassphraseKey : @"the_password",
                            NSMigratePersistentStoresAutomaticallyOption : @YES,
                            NSInferMappingModelAutomaticallyOption : @YES
                            };

I have a problem where the resulting NSPersistentStore* object is not created (returning nil) if using type EncryptedStoreType. The error code returned is also nil.

The SQLCipher library used is commercial iOS version, with openSSL already contained in that. The integration of SQLCipher seems ok, I am able to use encrypted database just fine when testing in the encrypted-core-data project.

Probably a long shot, but has anyone encountered a similar issue when integrating SQLCipher with Magical Record - any advice appreciated.

Thanks in advance 2J

Was it helpful?

Solution

I had this problem today, after much spelunking through EncryptedStore.m with log statements I discovered it was failing to create a new database because I had added an entity with index as an attribute name.

Turns out you're not allowed to use index as an attribute name.

I found my problem inside the loadMetadata: function in EncryptedStore.m so maybe start there if you haven't solved it yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top