Databases not keying properly in iOS 10?


#12

@sjlombardo It works in my SQLTest project, but not in my actual project. I can’t seem to figure out why. I installed the same Podfile on my SQLTest project and they are both using the same and latest version of sqlcipher.xcodeproj - not making much sense. I have tried cleaning the project and everything but same linker error overtime - thoughts on possible causes I could investigate?

Here is the other linker flags

-lsqlcipher (inherited) -ObjC -l"AFNetworking" -l"AGWindowView" -l"GGLAnalytics" -l"GGLCore" -l"GSDK_Overload" -l"GTMSessionFetcher_core" -l"GTMSessionFetcher_full" -l"GTMStackTrace" -l"GTM_AddressBook" -l"GTM_DebugUtils" -l"GTM_GTMURLBuilder" -l"GTM_KVO" -l"GTM_NSData+zlib" -l"GTM_NSDictionary+URLArguments" -l"GTM_NSScannerJSON" -l"GTM_NSStringHTML" -l"GTM_NSStringXML" -l"GTM_Regex" -l"GTM_RoundedRectPath" -l"GTM_StringEncoding" -l"GTM_SystemVersion" -l"GTM_UIFont+LineHeight" -l"GTM_core" -l"GTM_iPhone" -l"GoogleAnalytics" -l"MBProgressHUD" -l"Masonry" -l"ProtocolBuffers" -l"RNCryptor" -l"SSKeychain" -l"c++" -l"sqlite3" -l"stdc++" -l"uservoice-iphone-sdk" -l"xml2" -l"z" -framework "AVFoundation" -framework "Accelerate" -framework "AddressBook" -framework "AssetsLibrary" -framework "AudioToolbox" -framework "CFNetwork" -framework "CoreData" -framework "CoreFoundation" -framework "CoreGraphics" -framework "CoreImage" -framework "CoreLocation" -framework "CoreMedia" -framework "CoreMotion" -framework "CoreTelephony" -framework "CoreText" -framework "Crashlytics" -framework "Fabric" -framework "Foundation" -framework "GLKit" -framework "ImageIO" -framework "JavaScriptCore" -framework "MediaPlayer" -framework "MessageUI" -framework "MobileCoreServices" -framework "OpenGLES" -framework "PSPDFKit" -framework "QuartzCore" -framework "QuickLook" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" -force_load (PODS_ROOT)/GoogleUtilities/Libraries/libGTM_NSData+zlib.a


#13

The problem with iOS 10 and SQLite seems to be wider spread as my app (built in Xamarin, using SQLite .NET plugin) stopped working after the iOS 10 upgrade.


#14

@Steve_Djuroska can you provide some additional
Details? Is your app using SQLCipher with SQLite.NET or just the standard SQLite? What is the behavior you are seeing? Does it an existing app that is not work on iOS 10 or is it rebuilt against the latest SDK?


#15

Hi.
I’m not using SQLCipher. It’s a read only database with no sensitive data.
It’s an existing app already on sale that worked fine under iOS 9.xx and earlier.
Now, it stops responding on phones running 10 after firing two successful QueryAsync calls. At the 3rd call the ListView shows up empty, controls not-responding. iOS is not killing it.
I am in the process of updating XCode, macOS and Xamarin. Once done I will test it against the latest SDK to see the logs.


#16

The issue I’m experiencing does not happen to existing apps running on iOS 10 that were compiled before iOS 10. Those apps still work fine, it is when I build new apps in Xcode 8 and run them on iOS 10 that I experience my issue. Even still, the apps compiled in Xcode 8 still work properly on iOS 8 and 9.


#17

@tcoyle Could you please try the following at your earliest convenience?

  1. Remove the previous target-level configuration mentioned above (i.e. -lsqlcipher)
  2. Open up the project build settings (i.e. the global project settings, not the target)
  3. Locate the Other Linker Flags settings and add the following $(BUILT_PRODUCTS_DIR)/libsqlcipher.a
  4. Navigate down to the Target Build Settings, and verify that the resolved target-level Other Linker Flags shows the path to the libsqlcipher.a library first.
  5. Clean the Project, and attempt to rebuild

#18

@sjlombardo Hey Stephen

I did what you requested, build still fails but with a new error:

clang: error: no such file or directory: '...../Build/Products/DebugDEV-iphoneos/libsqlcipher.a'

#19

@tcoyle are you sure that you have SQLCipher integrated into that project using the sqlcipher.xcodeproj? In that case, there should be a libsqlcipher.a generated as part of the build process. Could you provide a full build log?


#20

@sjlombardo yes followed to specifications. I did the same on my sample project but its working there for some reason. Without the -lsqlcipher it builds fine.

I messaged you the build log.


#21

@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?


#22

@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.


#23

@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.


#24

@sjlombardo but if I build to a device running iOS 9 it does work properly?


#25

@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.


#26

@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.


#27

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.


#28

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 ?


Reading for Encrypted DB not working for iOS 10
#29

@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?


#30

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.


#31

@Nirav_Patel - Did you implement all of the guidance from this article?