SQLite for iPhone SDK
After asking on the MacRumors forums I was pointed back to FMDB that I had looked at a couple of days ago. FMDB is a Cocoa wrapper for SQLite3. I had a look at it, and after my initial difficulties, I found that I was trying a way to complicated way to use it for my iPhone applications. To add FMDB, simply do the following:
- in XCode in your project window, rightclick your “Classes” and Add -> “New Group”, call it FMDB
- drag the files from src in the FMDB package into the new group
- Rightclick Frameworks, Add -> “Existing frameworks”, select /Developer/Platforms/Aspen.platform/Developer/SDKs/Aspen1.2.sdk/usr/lib/libsqlite3.dylib and press “Add”
- Compile, smile and start using it
Leave a Comment
If you would like to make a comment, please fill out the form below.
Hi Niklas,
Thanks for the tip!
I’m particularly interested in accessing the sqlite databases where Apple stores sms messages and call histories. Have any idea’s there?
Cheers,
Josh
Sorry, I haven’t looked at accessing the rest of the system, I’m just working within the applications I’m writing at the moment
I’m quite a newb so thanks for the tips, but after following these steps I get this Xcode error:
duplicate symbol _main in …/fmdb.o and …/main.o
I already have a file with a main method, so how do I include FMDB?
Ah, nevermind, I looked at the source closer and realized that fmdb.o is not part of the actual FMDB wrapper.
Nevermind, I checked out the source more and realized that fmdb.m is not part of the wrapper itself.
Thanks for posting that info. I have been trying to figure out how to use SQLite on iPhone for a while now. I’ll give it a shot and report back.
The SQLite sample from the beta 5 iPhone SDL uses this frameworrk instead:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/libsqlite3.0.dylib
BTW, people that are thinking about accessing other parts of the system implemented as SQLite databases are out of luck. Each iPhone application is limited to its own “sandbox” and that’s it.
Hello.
I just started with with objective-c/cocoa/iPhone SDK and trying to get the FMDB wrapper working but when I try and compile a fresh project it says:
error: Cocoa/Cocoa.h not found
Any help would be greatly appreciated.
Thanks.
Make sure you’ve got the Cocoa framework included in your project
hi, how to create a table from iphone ?
I’m getting the same error that Oskar had on March 18, namely:
duplicate symbol _main in …/fmdb.o and …/main.o
How do I fix this? I’m using XCode 3.1.
Thanks,
Brian
You seem to have two definitions of the function main(). Try removing one of them