1

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

sqlite3 *database;

generates an error saying that sqlite3 is undeclared.

3 Answers 3

3
#import <sqlite3.h>
Sign up to request clarification or add additional context in comments.

1 Comment

To explain the problem and not just the solution: @awakeFromNib, you linked against the libsqlite3.0.dylib library (not a framework), but you did not import the header. You must import the header so that the compiler knows what SQLite terms you're going to use and how they can be used (e.g., function prototypes), and you must link against the library so that the linker can resolve these terms to actual functions for you to call.
0

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

1 Comment

Where does the question mention O-C?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.