@tcoyle I took a look at the build log. I didn’t see any evidence there that SQLCipher was actually being built. There should be a line there that reads “Build target amalgamation of project sqlcipher” if it is being compiled in. Is it possible that you removed the target dependency or link with library configurations while testing at some point? Can you double check the Build Phases on the application target please?
@sjlombardo it is the first thing listed under build phases
if it wasn’t being built why does it work if I remove the -lsqlcipher line? I keep comparing everything side by side with my SQLTest project and can’t figure out why one works and the other doesn’t.
@tcoyle Right, the thing is it’s not really working (from a SQLCipher perspective), its just compiling. Because your main project has pods that include sqlite3 dependencies, that is being used instead. This isn’t really a supported scenario, but I was thinking this might provide some sort of workaround. I’m not sure about the difference in the projects, but if you compare the two build logs it is clear the amalgamation and sqlcipher project build steps aren’t happening.
@sjlombardo but if I build to a device running iOS 9 it does work properly?
@sjlombardo so I decided to recreate my project from scratch - seeing as my sample projects worked fine and I couldn’t find any differences in build settings.
After getting further along the process I got the error again, and determined it has something to do with using different configurations/schemes.
In my main project I have a DebugDEV and DebugPROD configuration with different bundle identifiers. I have 2 schemes set up to quickly run this configurations. When building for iOS 10 - to one of this configurations - is when I receive the library not found error for sqlcipher. I added these configs and schemes to my test project and was able to reproduce the issue. I will message you a copy of the updated test project.
@sjlombardo alright I fixed it.
I had to add all the different configurations I use in my main project to the sqlcipher project to get it to build on iOS 10 devices. Never had to do that before - but for some reason it wasn’t building sqlcipher when building from those configs - only for iOS 10.
Thanks for the help, the -lsqlcipher lines a life saver.
Hi @tcoyle - It’s good to hear that you were able to resolve the configuration issue. I wanted to mention briefly that while the linker changes may work, they are not without risk. It is still possible that there could be other undefined behavior due to the concurrent linking of sqlite3. Unfortunately, this isn’t really a supported scenario. If you use decide to use this approach, please be cautious and especially careful with testing. You should also review the article we recently published about SQLCipher with XCode 8 and iOS 10, particularly related to the runtime verification of SQLCipher and testing.
Hi @sjlombardo - I am also facing one issue in sqlcipher in iOS 10.
-
I have done below code to encrypt DB.
sqlite3 db1;
if (sqlite3_open([[self.databaseURL path] UTF8String], &db1) == SQLITE_OK) {
const char key = [@“strong” UTF8String];
sqlite3_key(db1, key, (int)strlen(key));
if (sqlite3_exec(db1, (const char*) “SELECT count(*) FROM sqlite_master;”, NULL, NULL, NULL) == SQLITE_OK) {
NSLog(@“Password is correct, or a new database has been initialized”);
} else {
NSLog(@“Incorrect password!”);
}
sqlite3_close(db1);
}
Database encryption is working perfectly.
- Now if i am going to perform any operation on database than got error “file is encrypted or is not a database”
Can you pls help me ?
@Nirav_Patel - have you reviewed and implemented all of the guidance from the Important Advisory: SQLCipher with Xcode 8 and new SDKs?
Have you examined the database to ensure that it is actually encrypted?
Yes, My database is actually encrypted. But if i am going to perform any operation after encryption than got error which i send you above post.
@Nirav_Patel - Did you implement all of the guidance from this article?