XCode Not Copying Database

I've got an iPhone app that uses a SQLite database.  USED to work, until I built for distribution.  Now it's not working anymore.  It can FIND the database, and it can OPEN it, but can't READ from it.


1)  I added the database as an "existing file" to the resources directory of my project.
2)  I checked the checkbox "Copy this file's contents" in the popup when you add a file.
3)  I double-checked the original database before I copied it into the resource directory... 31M.
4)  I build the project.
5)  I checked the application directory for the build, and found that a file had been created that was the same name as my database file, but it was empty...  zero K in size.  No contents.
6)  When I ran the application, it found the database, and did an OPEN successfully... but when I tried to execute a "sqlite3_prepare_v2" statement, it returned a SQLITE_ERROR, which indicates that it can't read/find the database.

Any ideas?
Who is Participating?
eDistrictAuthor Commented:
The actual solution was much simpler... apparently, XCode has a bug that keeps it from copying the contents of a sqlite file if the file extension is anything other than .sql.   My database had a .db extension, and XCode was creating a file of 0k with that name, but was not copying over the contents.
Pieter MaraisLead DeveloperCommented:
Hi there,

You can try to delete it and then add it again to the resource folder, if you haven't tried it yet. As for trying to use the database, I had to make a copy of the database to the documents folder the first time the application ran on an iPhone.

Here is a link that will explain it better than I can:


Hope it helps ^_^
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.