[Last Call] Learn how to a build a cloud-first strategyRegister Now


XCode Not Copying Database

Posted on 2009-12-18
Medium Priority
Last Modified: 2013-11-25
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?
Question by:eDistrict

Expert Comment

ID: 26095565
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 ^_^

Accepted Solution

eDistrict earned 0 total points
ID: 26095687
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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question