0

I've seen several posts on this, and I've followed and rechecked the suggestions, but I still get

Use of undeclared type 'sqlite3'

My BridgingHeader.h file contains

#ifndef areabook_Bridging_Header_h
#define areabook_Bridging_Header_h

#import <sqlite3.h>

#endif

(The Link Binary With Libraries has libsqlite3.0.dylib. I have also used libsqlite3.dylib. The build never gets to the link phase so this is not the problem.)

BridgingHeader.h is referenced in the build setting Objective-C Bridging Header. I know I have BridgingHeader.h referenced correctly because if I change

<sqlite.h> to <sqlitexx.h> 

the compiler gives the error

'sqlite3xx.h' file not found

and I don't get the error when I use the correct name (sqlite.h).

Using sqlite.h in BridgingHeader.h, the compiler gives this error in my swift code.

import UIKit

class Db: NSObject {

    var database: sqlite3 = nil
                     Use of undeclared type 'sqlite3'
. . .

What, oh what, am I missing?

jimmyg
  • 580
  • 4
  • 13
  • 1
    You don't use the `sqlite3` type in Swift. Use `COpaquePointer`. See http://stackoverflow.com/a/28642293/1271826 for example. – Rob May 02 '15 at 04:25
  • use can use also for sqlite.swift wrapper for sqlite connectivity. see http://stackoverflow.com/questions/29454722/using-an-sqlite3-database-with-an-ios8-app-using-xcode-6-and-swift/29467871#29467871 for example – Memon Irshad May 02 '15 at 05:12
  • Rob, That's what I was missing: COpaquePointer. Thanks! – jimmyg May 02 '15 at 05:28

1 Answers1

0

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