Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue deploying to device #37

Closed
Gordiii opened this issue Nov 5, 2013 · 2 comments
Closed

Issue deploying to device #37

Gordiii opened this issue Nov 5, 2013 · 2 comments

Comments

@Gordiii
Copy link

Gordiii commented Nov 5, 2013

I've successfully encrypt and decrypted a sqlciphered db through using encrypted-core-data. All seemed fine until I deployed to an iPhone device. The issue appears to be in the method:

makeStoreWithDatabaseURL:(NSURL )databaseURL managedObjectModel:(NSManagedObjectModel *)objModel :(NSString)passcode

of EncryptedStore.m when the NSPersistentStore is created. The NSAssert reports the corresponding error. Here's a summary of my trial and errors by modifying the NSURL variable databaseURL in the method:

makeStore:(NSManagedObjectModel *)objModel :(NSString *)passcode

On Simulator

Test A:
databaseURL = [applicationSupportURL URLByAppendingPathComponent:[@"Preload" stringByAppendingString:@".sqlite"]];

Test A Result:
Error Domain=NSSQLiteErrorDomain Code=14 "The operation couldn’t be completed. (NSSQLiteErrorDomain error 14.)" UserInfo=0xc46e5e0 {EncryptedStoreErrorMessage=unable to open database file}

Test B:
databaseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Preload" ofType:@"sqlite"]];

Test B Result:
Success --> Loads the data as intended in the simulator

On Device (iPhone)

Repeat Test A:
Error Domain=NSSQLiteErrorDomain Code=14 "The operation couldn’t be completed. (NSSQLiteErrorDomain error 14.)" UserInfo=0x15d5fd40 {EncryptedStoreErrorMessage=unable to open database file}'

Repeat Test B:
Error Domain=NSSQLiteErrorDomain Code=8 "The operation couldn’t be completed. (NSSQLiteErrorDomain error 8.)" UserInfo=0x14e4e180 {EncryptedStoreErrorMessage=attempt to write a readonly database}'

The main difference is the path in which the sqlite resides:

For Test A:
file:///Users/hkbc02/Library/Application%20Support/iPhone%20Simulator/7.0.3-64/Applications/D0864B56-840A-455F-9B52-EB75FE258FD1/Library/Application%20Support/Preload.sqlite

For Test B:
file:///Users/hkbc02/Library/Application%20Support/iPhone%20Simulator/7.0.3-64/Applications/D0864B56-840A-455F-9B52-EB75FE258FD1/MyAppName.app/Preload.sqlite

Any ideas what I might have done wrong?

@Gordiii
Copy link
Author

Gordiii commented Nov 6, 2013

In EncryptedStore.m I changed:

FROM

NSURL *applicationSupportURL = [[fileManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject];

TO

NSURL *applicationDocumentsDirectory = [[fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

in the method:

(NSPersistentStoreCoordinator *)makeStore:(NSManagedObjectModel *)objModel :(NSString *)passcode

to fix the problem.

@Gordiii Gordiii closed this as completed Nov 6, 2013
@gavin-black
Copy link
Member

Interesting, I'm guessing this has to do with iOS 7. Going to try adding your change, make sure it has backwards compatibility with everything, and then make it the default if it does. Adding a new ticket for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants