node ninja
node ninja

Reputation: 32986

How to use sqlite3 in XCode

I imported the libsqlite3.0.dylib framework but this code

sqlite3 *database;

generates an error saying that sqlite3 is undeclared.

Upvotes: 1

Views: 3260

Answers (3)

Sunny
Sunny

Reputation: 63

Download Sqlite3 source from https://www.sqlite.org/download.html

Add Library(libsqlite3.0.dylib or libsqlite3.0.tbd) to project.

Add headers from downloaded source.(sqlite3.h,sqlite3ext.h).

Just #import "sqlite3.h" where you are creating sqlite3 object.

Upvotes: 0

Sk Rejabul
Sk Rejabul

Reputation: 7

In objective-c use this code:-

#import <sqlite3.h>

And Swift:-

Follow this steps:- Use FMDB which is an Objective-C wrapper around SQLite database. You may ask that how to use an Objective-C framework in a Swift project.

Briefly, you must :-

1. Download FMDB framework     
2. Add it to your project  
3. Create a Bridging Header
3.1 remember to change Defines Module in Build Settings for FMDB to Yes
4. Use import "sqlite3"  where you wanna use it

Upvotes: 0

sonics876
sonics876

Reputation: 957

#import <sqlite3.h>

Upvotes: 3

Related Questions