" _sqlite3_key"找不到架构i386的符号

时间:2014-03-19 16:43:50

标签: ios sqlcipher

您好我使用此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);
    }

任何人都知道如何解决这个问题?请帮帮我!!!

2 个答案:

答案 0 :(得分:1)

您没有为i386编译它 - 查看教程

将i386添加到有效的archs&amp;要建造的拱门。

enter image description here

=&GT;只有SIMULATOR是i386

答案 1 :(得分:0)

默认情况下,不再为armv7s架构构建最新的Xcode更新。

当前的Xcode 6等将 $ {ARCHS_STANDARD} 定义为 armv7,arm64

enter image description here

此外,每当您更新Xcode时,它一直在纠缠您删除自己对要构建的架构的定义,以便它可以为您做出决定。如果你坚持这个坚持,那么你会发现你将不再为armv7s建造你的东西。

armv7s 指令集可在Apple的A6(iPhone 5)和A6X(iPad 4)CPU中找到。以下Apple A7(可在iPhone 5S,iPad Air,iPad Mini Retina中找到)已经转移到64位架构 arm64

当Apple向Xcode添加了对armv7s构建的支持时,他们混淆了很多使用二进制版本的第三方库的开发人员,比如SQLCipher。

修复很简单 1.在左侧导航区域中单击项目
2.单击构建设置
3.在内部体系结构中,您可以在其他SDK下方看到另一个体系结构,单击它将获得两个选项
- 标准体系结构(armv7,arm64)
- 其他
4.选择其他,然后您将获得另一个弹出窗口,因为您已经有一个名为 $(ARCHS_STANDARD)的条目,因为您需要添加另一个名为的条目armv7s ,点击popover底部的“+”按钮。
如下所示enter image description here 然后,开发人员的链接器将选择应用程序所需的架构切片。

5.如果有效架构,如果架构 armv7s 不存在,则添加它。

完成所有这些后,您的主架构应如下所示

enter image description here