开发者

libsqlite in simulator and iOS compiling

I'm having some issues when compiling my app to iOS. I'm using sqlite3 and imported as

#import <sqlite3.h>

Well, I only found a file named libsqlite3.0.dylib in my Mac and I copied it to my project. When I compile it for iOS Simulator, it works just fine. However, when I try to compile the app for iOS Device, it throws an error (Apple Match-O Linker Error) in every call I do in my implementation to s开发者_JAVA百科qlite's function (such as _sqlite3_open, etc.)

How can I compile it to iOS Device?

Thank you!


Instead of simply copying the library, do it like this:

  • in Xcode Navigator, click on your target (the upmost entry)

  • go to Build Phases, then Link Binary With Libraries

  • add the libsqlite3.dylib from it's location at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/


Just in case someone faced that same problem as me. If you are unit testing your code, add the lib file also to your test target.


Did you try to import sqlite3 library like:

#import "sqlite3.h"

instead of:

#import <sqlite3.h>


The best way that I have found to use SQLite in your IOS application is to build your own copy of the SQLit library and include it in your project. libsqlite3.0.dylib is a very old copy of SQLite.

You can easily download the SQLite Amalgamation source code and build it for IOS. this gives you the latest SQLite source code that has all the latest bug fixes and improvements.

If you can open Xcode and create a new static library project, then you are 75% of the way there.

Once you have the static library project, include the SQLite sources that you downloaded from the SQLite Amalgamation and set a few Preprocessor options and your off and running with the latest code.

For complete details and sample source code you can visit my blog conedogers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜