开发者

How to Test Core Data Migration With an App Already in the App Store?

We have an app that is currently in the app store. It uses Core Data as its persistence mechanism. We have a new version ready to go, and it has some schema changes. Specifically, we have added 1 new entity and added a new attribute to an existing entity. From my understanding and reading, this is one of the most simple migrations that can occur. There are no field deletions, and no relationships to change. The data model consists of 5 entities with no relationships at all.

We have versioned the data model, and created an .xcmappingmodel to handle the migration. We are handling the migration by adding the following options to the creation of the PersistentStoreCoordinator:

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                     [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, nil];

Currently, we have tested successfully with several members of the team using the following process:

  1. Delete all test versions of the app from the device and from iTunes
  2. Go to the app store and download the current version
  3. Make some changes to the app that will prove the migration was successful
  4. Drag the new binary (signed with the same bundle identifier) into iTunes and sync
  5. Load the new version on the device, verify that the changes made in the previous version are still present, and that the app does not crash

My question is this: Is there an easier/better way to test this? Our concern is that once the app goes out the door, there is no other wa开发者_运维知识库y to ensure our users have the best experience possible.


I've been using Core Data for my app and upgraded about 7 times, migrating from old models to new models.

Whenever, I am prepared to release the next version, I always test migration by using Model Mapping. As long as I made every entity and attribute of source model is matched against corresponding entity and attribute of destination model, I've experienced no problem.

Testing with your own project files are just as same as testing released ones that are distributed to the customers, so you don't have to worry if your test for migrating old model to new model is valid.

In other words, your project bundle's target, which is going to be archived and submitted, is same as what's being downloaded by the customer.

I'm pretty confident this is the case, since I've done testing with different versions of my app with no problem.


Yes.

I hope you're managing your source code in a source code management system. If not, start as soon as possible. Xcode 4 provides git built in, if you don't have another, use that one.

If you have the old source code, keep two different directories, the 1.0 build (that's now in the store), and the 1.1 build. If you can manipulate the data that will be effected in the simulator, that's ideal.

You're storing your core data in a file in the app, it's now somewhere like /Users/bshirley/Library/Application\ Support/iPhone\ Simulator/4.3.2/Applications/6D18BD0E-70C1-41FB-9BE8-F736CAAA9FFC/Documents/MyApp.sqlite

You can copy that out of the directory, add it as a resource in the new app, and perform the conversion every time you freshly install on the sim/device. You can drop in any new version of the old format to test out different data sets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜