“_sqlite3_key” Symbol(s) not found for architecture i386

江枫思渺然 提交于 2019-12-13 12:18:02

问题


Hi I used this SQLCipher(http://sqlcipher.net/ios-tutorial/) to encrypt my sqlite but when I compile I met this error

 "_sqlite3_key", referenced from:

 -[LCAppDelegate application:didFinishLaunchingWithOptions:] in LCAppDelegate.o

 Symbol(s) not found for architecture i386

It happened when I used this code in my 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);
    }

Anyone know how to solve this? Please help me !!!


回答1:


You didnt compile it for i386 -- looking at the tutorial

add i386 to the valid archs & the archs to build.

=> only the SIMULATOR is i386




回答2:


The latest Xcode update no longer builds for the armv7s architecture by default.

The current Xcode 6 and so on, defines ${ARCHS_STANDARD} as armv7, arm64.

Also whenever you update Xcode it keeps pestering you to remove your own definition of what architectures to build so that it can decide this for you. If you give in to this insisting then you find that you’ll no longer build your things for armv7s.

The armv7s instruction set is found in Apple’s A6 (iPhone 5) and A6X (iPad 4) CPUs. The following Apple A7 (found in iPhone 5S, iPad Air, iPad Mini Retina) already had moved to 64-bit architecture arm64.

When Apple added support for building armv7s to Xcode they confused quite a few developers who were using binary builds of third party libraries, like SQLCipher.

The fix is quite simple
1. In your left navigation area click on project
2. Click on Build Settings
3. Inside Architectures you can see another Architecture below Additional SDKs, click on it you will get two options
- Standard architecture (armv7, arm64)
- Other
4. Select Other then you will get another popover in that there will already be an entry called $(ARCHS_STANDARD) , in that you need to add another entry called armv7s by clicking on the "+" button at the bottom of popover.
As shown below The developer’s linker will then pick out the architecture slices it needs for the app.

5.If in Valid Architecture if the architecture armv7s is not there, then add it.

After doing all this your main Architectures should look like below



来源:https://stackoverflow.com/questions/22512614/sqlite3-key-symbols-not-found-for-architecture-i386

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!