PREMKUMAR PREMKUMAR - 2 months ago 39
Swift Question

Swift Can't Import Sqlite3 iOS

I added

libsqlite3.0.dylib
to my project, and then I tried to import using the following code:

import UIKit
import sqlite3

class Dataware: NSObject
{

}


But it's giving me this error:

No Such Module 'sqlite3'

Answer

Add it to your Bridging-Header.h file:

#import <sqlite3.h>

This is the primary mechanism for importing any C-language libraries.

If you don't yet have a Bridging-Header.h file:

  1. Add a file Bridging-Header.h (or more typically (ProjectName)-Bridging-Header.h
  2. Go to the build settings tab for your project
  3. Find "Objective-C Bridging Header". The easiest way is to search for bridging.
  4. Enter the name and path for the file you created in step one. It's probably (ProjectName)/(ProjectName)-Bridging-Header.h