简体   繁体   中英

Core data migration in app store app

In my app I am using core data and uses version 1 to 5. In app store eg previous app have version 1 and the new update have version 5. So version 2,3,4 are skipped in debug and ad hoc releases. Now I found that the app store crashes due to some kind of core data problem, and I think its for the versioning issues. If the old app is removed and new app installed, it resolve the problem.

Can you suggest me how can I resolve this issue? Keeping existing app installed in the user phone and release a new update so that people who have earlier version need not to remove the app for updating.

I look for migration scheme. I could not find any intuitive documentation how can you migrate or fix when you screw up your own xcdatamodel file with older version.

Since in my case, there was no important data stored and all data were dynamic related to the current run of the app, in the next release I delete my old sqlite files in the documents directory and make a clean up. I use another sqlite file to store new data from now on...

It just happened to me too. I had tested over and over again... the migration was working fine and when the app went live, the migration was not working with the app that was coming from the AppStore.

Solution : Test the migration by installing the app through iTunes, not through XCode.

How : Delete the app from your iPhone. Sync with iTunes. Make sure the app is removed from the Apps in iTunes. Install the old app through XCode to your device. Now open up in XCode the new version of your app. Select to build for an iPhone device (not for the simulator). Find the .app file in /Users//Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphoneos Drag the .app file in iTunes. Sync with your device.

This way, the new app will overwrite the old one in your iPhone in the exact same way as it happens when you upgrade through the AppStore.

Now, you can put debug logs and find out what your problem is. You can see the logs in the Organizer, in the Console of your device.

In my case, the problem was that pathForResource method is not looking into subdirectories. But my old mom file was in a directory. So I had to use the extra parameter "inDirectory" of the same method.

The reason why this method worked when installed through XCode and did not work through iTunes beats me... no clue !!!

But at least now I know tho things : - pathForResource does not look into subdirectories - Always install my app through iTunes before going live !!!

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