sqlcipher 在 iOS 10 时停止工作

sqlcipher stopped working in iOS 10

我在我的 iOS 数据库项目中使用了 Sqlite (sqlcipher)。在 iOS 9 中,一切都运行良好。现在我更新了新的 Xcode。但是数据库加密现在不起作用。

sqlite3 *db1;
    if (sqlite3_open([[self.databaseURL path] UTF8String], &db1) == SQLITE_OK) {
        const char* key = [g_sqlite_key UTF8String];
        AZLog(@"%s",key);
        sqlite3_key(db1, key, (int)strlen(key));
        if (sqlite3_exec(db1, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
            AZLog(@"Password is correct, or a new database has been initialized");
        } else {
            AZLog(@"Incorrect password!");
        }
        sqlite3_close(db1);
    }

谁能帮帮我?

提前致谢

Xcode8 和新的 SDK 有很多变化。请参考此指南:

https://discuss.zetetic.net/t/important-advisory-sqlcipher-with-xcode-8-and-new-sdks/1688

使用 sqlcipher 加密数据库时,您必须提供读写和打开创建权限。

sqlite3 *db1;
    if (sqlite3_open_v2([[self.databaseURL path] UTF8String], &db1, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) == SQLITE_OK) {
        const char* key = [g_sqlite_key UTF8String];
        AZLog(@"%s",key);
        sqlite3_key(db1, key, (int)strlen(key));
        if (sqlite3_exec(db1, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
            AZLog(@"Password is correct, or a new database has been initialized");
        } else {
            AZLog(@"Incorrect password!");
        }
        sqlite3_close(db1);
    }