Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 18, 2008, 12:47 PM   #1
ews2001
macrumors newbie
 
Join Date: Sep 2008
Update existing SQLite DB within XCode Project

After I created my sqlite database in the terminal window, I then added the file as a resource to my project and I'm able to access the data.

However, I've tried over 20 different ways to edit the data in the database or start over with a new database (using the terminal, cleaned the project, deleted the resources then added them back in) and NOTHING has worked.

What am I doing wrong?
ews2001 is offline   0 Reply With Quote
Old Sep 18, 2008, 01:08 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
You're trying to replace the database from within Xcode?

What you described should have worked. Sometimes Xcode doesn't always copy a resource over, but cleaning should fix it.
kainjow is offline   0 Reply With Quote
Old Sep 18, 2008, 01:25 PM   #3
ews2001
Thread Starter
macrumors newbie
 
Join Date: Sep 2008
Yes, I'm trying to update the SQLite database with new data, I want to insert some new rows and change some column data types.

Some things I've attempted:
Deleting all instances of my_old_database.sqlite files within my project folder, removing it as a resource. Then I go into terminal, create a new project, ie: my_new_database.sqlite and add it as a resource.
I clean the project
Build the project and in my iPhone simulator the old data is still there...

What am I doing wrong here?
ews2001 is offline   0 Reply With Quote
Old Sep 19, 2008, 09:00 AM   #4
caldwelljason
macrumors member
 
Join Date: Jul 2008
if you're following the sample code on using sqlite, it has you copying the db from the resources to the user's directory and using that copy. There is a safegaurd to prevent copying over a user's data. So if you replace the db in the project, your code will still see the existing db in the user directory and not copy your new db.

Hope that helps.
caldwelljason is offline   0 Reply With Quote
Old Sep 19, 2008, 10:01 AM   #5
Pring
macrumors 6502
 
Join Date: Sep 2003
I usually manually delete my old Application from ~/Library/Application Support/iPhone Simulator/User/Applications (path from memory as I'm at work, may be slightly wrong)

That forces it to copy the entire new app to the Simulator.
__________________
Dardan Software
Neil Inglis' Blog
Check out Escape Pod and Alphonetic on iTunes!
Pring is offline   0 Reply With Quote
Old Sep 19, 2008, 11:39 AM   #6
ews2001
Thread Starter
macrumors newbie
 
Join Date: Sep 2008
Thanks for your help, everyone.

The only way I was able to get it to work was by manually removing the old database from my Documents/Project_Name folder, then I scripted a new sqlite DB (naming it different) and saved it within my Project_Name folder, added it as a resource, then renamed all references of my new DB within my application files (appDelegate and others).

I guess this is the only way to go about it...just frustrating to have to rename all references to the new DB within my application itself each time I want to update my sqlite DB file.

There has to be an easier way...
ews2001 is offline   0 Reply With Quote
Old Sep 19, 2008, 12:29 PM   #7
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
I have a similar situation. I just have some code that deletes the existing db in the Documents folder and then writes a new one there. This code will obviously only run in my debug builds. I copy in a new db every time the debug app launches.

You could also write code that checks the mod dates on the two db files and deletes the one in the Documents dir if its date is older than the one in the app.

Another thing I do is write a version number into a table in the db. I have a currentVersion constant in my app. When the app is going to load a db it checks the version number in the db and if it doesn't match the current one in the app it deletes the db file and rebuilds it. I bump the currentVersion every time I make a change to the db schema, which can happen multiple times per day during development.
PhoneyDeveloper is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Where does Xcode save project snapshots? MacMan988 iPhone/iPad Programming 2 Mar 28, 2014 03:32 AM
Convert Applescript to Xcode Project omgitssum1 Mac Programming 3 Feb 26, 2014 03:57 AM
How do I migrate an Xcode project from one Mac to another? moonman239 Mac Programming 4 Feb 8, 2014 05:53 PM
Why can't I open this Xcode project? dalem Mac Programming 4 Jan 14, 2014 02:15 PM
Sqlite3 database Standards and properties : From .CSV or .XLS to .sqlite in Xcode 4.3 EliasRahme iPhone/iPad Programming 0 Jul 21, 2012 02:53 AM

Forum Jump

All times are GMT -5. The time now is 08:19 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC