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 !!!
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
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