Pompey Casmilus
Pompey Casmilus

Reputation: 205

Importing existing sqlite db into Swift project

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.

Upvotes: 3

Views: 3372

Answers (1)

Peter Andrew
Peter Andrew

Reputation: 103

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

check

Upvotes: 4

Related Questions