简体   繁体   中英

Core Data Versioning, always loading the previous version

I have done lightweight versioning in my project, right now i have two versions and the current version is set to latest one(dataModel 2.xcdatamodel for example). I have followed every steps there in the apple document. But it's crashing every time because the old version is loading(found that after debugging, the new attributes are missing in the entity) after fresh installation.

If i switch back to old version and roll back to current version again then it's running fine. I have deleted the references and added it again but the result is same.

My source code is on git and its very annoying to do that extra effort every time. Please help me to solve this problem.

thanks :)

If you are 100% sure that the new version is loaded, it means that you created the new version, started the app, applied changes to the model, started the app again. To eliminate the possibility of it, just create the 3rd version based on the 2nd version and make it current active. Also make sure you have the automated lightweight migration implemented as per apple manual here

https://developer.apple.com/Library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html

I am not sure, i guess it is a git/svn problem. We had to work with different versions of Xcode from the very beginning of the project. Whenever we committed to the git, the git found a miss match of Xcode versions(for say i am working with Xcode 5.1 and my team mate working with Xcode 5.0.1, the project was initialised with Xcode 4.1) and set the current core data version to the very older one that is dataModel 1.xcdatamodel in my case. That's why the project was running fine in my side but when my team mate pulled my code from the git and tried to run in his side it crashed everytime because the version was set to older one by the git.

I got this from here . After following the instructions the problem is solved for now.

Thank you all. If you have any better solution please share.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM