【发布时间】:2014-03-19 16:43:50
【问题描述】:
您好,我使用这个 SQLCipher(http://sqlcipher.net/ios-tutorial/) 来加密我的 sqlite,但是当我编译时遇到了这个错误
"_sqlite3_key", referenced from:
-[LCAppDelegate application:didFinishLaunchingWithOptions:] in LCAppDelegate.o
Symbol(s) not found for architecture i386
当我在 AppDelegate 中使用此代码时发生这种情况
#import <sqlite3.h>
...
NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
stringByAppendingPathComponent: @"sqlcipher.db"];
sqlite3 *db;
if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
const char* key = [@"BIGSecret" UTF8String];
sqlite3_key(db, key, strlen(key));
if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
// password is correct, or, database has been initialized
} else {
// incorrect password!
}
sqlite3_close(db);
}
有人知道如何解决这个问题吗?请帮帮我!!!
【问题讨论】:
-
你需要在你的项目中添加 libsqlite3.dylib
-
并且只构建活动架构到是