views:

23

answers:

2

Hi there

Basically when I have an application in XCode and I change the sqlite/coredata database and try to run it on a device that already has the application on it then the app crashes. I have to remove the app and reinstall it.

I have updated the database on an app that has already been submitted to the app store. There has been about 100 downloads, and now I want to submit the update. Will people who have already downloaded it have problems with it? How would I make sure that they don't? There won't be any data in the old database that I will need to be honest, but I'm worried that the app just won't start at all.

Thanks Tom

+1  A: 

Yes the app will probably crash when running with old db.

Apple released an interesting documentation about Core Data versioning and migration called: Core Data Model Versioning and Data Migration Programming Guide

If you read this document, you will learn how to avoid the crashes with updated coredata databases.

Junior B.
thanks for that link... I understand now, I didn't realise about versioning and such before... :( now I know I'll do that in the future... but for now I have changed the model and don't have the original. I might be able to find it in a backup somewhere... would that be the best thing to do?
Thomas Clayson
+1  A: 

From your description I can tell that you've changed the Managed Object Model withtout changing the store version.

Check out this tutorial (may be Mac version, but it should be valid) here.

However, if you with to omit the migration (since you said users won't exactly have any data in the store) you can always change the store path so that it loads another store. However, if you plan any updates and further developement of the app then i strongly recomend to read about core data migration.

Pawel
Yeah, I didn't know about migration. I just changed the original model.. :/ oops. I can probably find a copy of the old version somewhere in a backup file somewhere... :/ thanks for the link, I'll have a look now.
Thomas Clayson
How would I change the store path? Will this mean that the app won't crash for people who have already bought the app?
Thomas Clayson
I guess that somewhere in your code you're using [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]. The URL should be constructed from [[NSBundle mainBundle] pathForResource:@"ModelName" ofType:@"mom"], where ModelName is the path for the ManagedObjectModel store. If you change it to ModeName1 it should stop using the old model, however you'll loose all the data. Also remember to remove the sql store (or also change the path to it). Still, managing versions is a much better idea. Cheers, Pawel
Pawel