Use of unresolved identifier 'sqlite3_key' in XCode 9 iOS 11

My project written in Swift has been using SQLCipher from the App’s first version, It really did a good job until I recently upgrade it to XCode 9 to support iOS 11. It shows errors " Use of unresolved identifier ‘sqlite3_key’".

I had repeated the install instruction for more than 3 times, and also a totally new installation, SQLCipher still refuses to work.

Other C Flag checked, ‘#define SQLITE_HAS_CODEC 1’ and ‘#import <sqlite3.h>’ are both in bridge file.

Did I miss any step that need to change for XCode 9?

Thanks.

By the way, I have another new project written in Objective-C. After cloning SQLCipher project code using Git, it shows error Implicit declaration of function ‘sqlite3_key’ is invalid in C99, I found some files are in red which means not found in the project.

Source

  • sqlite3.c
  • sqlite3.h

FrameWorks

  • Security.framesorks (All)

Products

  • SQLCipher.framesorks (All)

I had to copy the old files from old project to make it works.

Hello @jdleung - please check out this information on using SQLCipher with XCode 9:

@sjlombardo, I followed your instruction to use the following code to test if SQLCipher is running, I got “true”, but if I used ‘sqlite3_key’ again the error Use of unresolved identifier ‘sqlite3_key’ happened. The settings is as same as the Objective-C project, but it fails in Swift. In the same project, database without encrypted can be opened without any error.

var is_sqlcipher = false;
    var stmt:OpaquePointer? = nil;
    if(sqlite3_prepare_v2(db, "PRAGMA cipher_version;", -1, &stmt, nil) == SQLITE_OK) {
        if(sqlite3_step(stmt) == SQLITE_ROW) {
            let ver = sqlite3_column_text(stmt, 0);
            if(ver != nil) {
                is_sqlcipher = true;
            }
        }
        sqlite3_finalize(stmt);
    }
    print("is sqlcipher: \(is_sqlcipher)")

@sjlombardo, I create a new project in Swift, SQLCipher runs without error.:joy:

I think there is other sqlite reference in the project, but libsqlite3.dylib had been removed before, and the project has run well before upgrading to XCode 9.

Any other frameworks must be removed?

Thanks.

Hello @jdleung - if there are other components that reference SQLite, you should take a look at this guidance as well related to the link ordering.

This isn’t specific to XCode 9, but it sounds like you might have some cross dependencies that might need to be addressed.

Hello @sjlombardo, thanks your guidance, the project do has two CocoaPods frameworks. I tried to remove them and then reinstall them with the latest version, SQLCipher works now.

Hello @jdleung - It’s good to hear that things are working for you. Just to clarify, did you upgrade the other Pods, reorder your pods in the spec, or do something else?

As an aside, it would be a good idea to implement the runtime checks mentioned in the above articles.

Hi @sjlombardo, I just removed and upgraded all the Pods without reordering.