Question

Working with an xcode project with a bunch of issues and TONS of unused/buggy legacy code - we recently made the decision to start a new project fresh and build up from there. Everything is much better, but I'm running into a core data migration issue.

The vast majority of this model is the same, with a few tweaks - the model only includes 6 objects and there's only one object that I really care about getting what the user has saved so when we release this and they upgrade that data is there. I created the new model basically from scratch in the new project, so I'm guessing the app is trying to access a specific model based on an ID or something that doesn't match?

Does anyone have any idea as to a potential solution?

The app is crashing at the assertion below:

NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil withConfiguration:nil options:options error:&error];

NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error);

The existing app is currently on its second version of the original ModelA, and the new app only has a single new fresh ModelA on the first version. I'm guessing that might have something to do with it?

Was it helpful?

Solution 2

I ended up doing my own heavy-weight migration. I added the old data model into the new project and did a one-time migration of the legacy objects to the new objects, storing them in the new database.

OTHER TIPS

I was going to comment, but my response was too long...

A silly question first... and I write this having never used RestKit...

Question One - Is it worth checking through any required Build Settings for RestKit in your new project?

Question Two - Shouldn't you include a value for fromSeedDatabaseAtPath in the method?

Pending satisfactory response to Question One, try this...

1st; Close your new project in Xcode. Open a Finder window, and use Finder to copy the old .xcdatamodeld file from your old project into the new project directory/folder, and rename the file name if necessary.

2nd; Open Xcode, and in your new project, select the 'Add Files to Project...' option in the File menu, and follow the prompts to add the old .xcdatamodeld file into your project.

3rd; In your code, create an NSString to represent the path to the old .xcdatamodeld file, and include that in your line of code after fromSeedDatabaseAtPath: for the method addSQLitePersistentStoreAtPath:fromSeedDatabaseAtPath:withConfiguration:options:error:.

Does that help?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top