Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing existing sqlite db into Swift project

Tags:

sqlite

swift

I have not developed anything for IOS in a long time so please bear with me. Using the Swift language for the first time in XCode 6.3. I have a pre-existing sqlite database, myDB.sqlite, that I want to import into my project.

I have added the sqlite Framework, added FMDB and the bridging header file and then added the myDB.sqlite file to my project. It is also included in "Copy Bundle Resources".

I am just trying to access myDB.sqlite in my bundle directory to copy it to my Documents directory when the app is run for the first time in the Simulator. However it keeps saying it cannot find the file.

In my AppDelegate.swift:

let dbPath = NSBundle.mainBundle().pathForResource("myDB", ofType:"sqlite")

It keeps telling me that dbPath is nil.

like image 498
Pompey Casmilus Avatar asked Nov 28 '25 06:11

Pompey Casmilus


1 Answers

Check the target membership of your SQLite database and it's done:

check

like image 63
Peter Andrew Avatar answered Nov 29 '25 23:11

Peter Andrew