0

we released an update of our App to Appstore the new version works very well at the simulator and our dev devices, but if you make an update from the Appstore the App crashes on startup unless you delete it and reinstall it. You can only see the starting screen and after 1 second the app crashes. I searched the other topics about that and found that it could be the Core Data Migration, but we are using Core Data only with InMemoryStore. Is it necessary to Migrate the Database?

Mundi
  • 79,884
  • 17
  • 117
  • 140
Weini
  • 123
  • 2
  • 7
  • In `-application:didFinishLaunchingWithOptions:` method, did you set rootViewController for keyWindow? or just addSubView to window? – Elf Sundae Jul 16 '13 at 13:33
  • No i use the storyboard to set the rootViewController – Weini Jul 16 '13 at 13:37
  • You're just guessing about what causes the crash, you really have no idea. You need to get some crash logs and symbolicate them to find out where the crash is occurring. Assuming that you know what caused the crash with no evidence is a complete waste of your time. – Tom Harrington Jul 16 '13 at 15:53

1 Answers1

1

If you changed the data model for Core Data then you need to migrate the database. Otherwise when you attempt to use Core Data it'll crash the application. If your data model didn't change then the problem is elsewhere.

  • ok thanks, we changed the data model, but we only use in memory store and don´t save any data when the app will be closed... is it also necessary to migrate? – Weini Jul 16 '13 at 15:04
  • Best way to tell would be to load the old version of your app on a device, run it and then debug the new version and see what the error output is. If it is the data model then it'll output "The model used to open the store is incompatible with the one used to create the store". – Brandon Campbell Jul 16 '13 at 15:21
  • i tried this several times and i didn´t get an error. The error only occur if i update it from the Appstore, but i can´t recreate it anymore because i don´t have a device with the old version of the app to try the update. – Weini Jul 16 '13 at 15:28
  • Are you using the NSManagedObjectContext anywhere in your code to instantiate the Core Data objects in memory? If so then the model is the problem. – Brandon Campbell Jul 16 '13 at 15:30
  • *"i can´t recreate it anymore because i don´t have a device with the old version of the app to try the update." Then **you need to get one**. Delete the app from a device, reinstall the old one, and then do the update. You need to observe what's happening to find the problem. – Tom Harrington Jul 16 '13 at 15:59
  • I user MagicalRecords to instantiate the Core Data objects. There the ManagedObjectContext will be created with [NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:coordinator]; – Weini Jul 16 '13 at 16:09
  • If i delete the app and reinstall the old one with iTunes and then try to update with the Appstore the error doesn´t occur. – Weini Jul 16 '13 at 16:13
  • You need to run the old app and force it to create the database file. What I believe happens is that the first time you access the NSManagedObjectContext the database file is created (other stuff happens too) and the context is returned. On subsequent app launches it will try and validate the database table structure with the data model. If they don't match you get the crash with the error I stated above. – Brandon Campbell Jul 16 '13 at 16:59
  • @BrandonCampbell that doesn't make sense if they're using only in-memory stores, because there won't be any database file. Right now they're only randomly guessing that it might be Core Data related, though they haven't gathered any crash reports or other details that would indicate what really happened. – Tom Harrington Jul 16 '13 at 18:23
  • @TomHarrington I agree right now we are just guessing. I'm trying to interpret "in-memory" stores I guess. From what I understand of Core Data as soon as you use an NSManagedObjectContext object it'll create a database file regardless of whether you write to it or not and on subsequent launches it'll validate the data model against that file. – Brandon Campbell Jul 16 '13 at 18:36
  • @BrandonCampbell "in-memory" stores, by definition, do not create data store files. That's what "in-memory" means. – Tom Harrington Jul 16 '13 at 20:38