Apple's Cloudkit Migration - ios

This may be too simple of a question for SO, but for those that have used both Cloudkit/Core Data, do you have to migrate data in Cloudkit similar to Core Data if you make any changes to the database itself?
For example, if you adjust your Core Data model at all, you have to go through a migration process in order to make sure the App still works appropriately. Is Cloudkit the same way?
From my understanding there is no migration process necessary (judging when I make changes and run them in the simulator just fine), but I want to confirm before I upload to the App Store. Thanks for any help!

This is covered in detail in the Deploying the Schema section of the CloudKit Quick Start.
The quick summary is that you do need to push changes to production using the CloudKit Dashboard. But keep in mind that you can only make limited schema changes so plan ahead well. You can add new fields. You can add new record types. You can't delete anything.
Keep in mind that users of your app will be using old versions as well as new versions. The latest version of the app will of course know about any new additions to the schema. Old versions of the app won't know about the new fields and record types.

Related

Lightweight CoreData Migration with CloudKit

Does Core Data handle simple data-model additions like a new attribute w/out any further "help" from me? In my case, I have an app that uses Core Data for varius things related to a users profile. I have an existing data-model entity called Profile that I want to add 2 new attributes to:
hasPublished: Boolean
lastDetail: String
So, does this cover my case? I'm not re-naming anything, just adding.
One more caveat, I'm using a NSPersistentCloudKitContainer as info can be shared across the users devices.
Yes it can handle, but there is some little work from your side.
You need to create new version of Core Data model.
Call initializeCloudKitSchema() so changes are uploaded to CloudKit.
Don't forget to deploy changes to production from CloudKit dashboard.
Remove initializeCloudKitSchema() when deploying your app to AppStore.

iCloud and lightweight migration

I've a published app synchronizing a Core Data with iCloud.
I need to update the model adding two attributes and then populate these new fields.
I've tested lightweight migration locally and works fine, I can see the old data migrated into the new model scheme.
When I activate iCloud, old data saved in the ubiquity container doesn't sync with the new model schema.
What is the expected behavior?
Should I be able to sync data both on old and new model versions?
How can I achieve it and test this situation?
I've read:
CoreData versioning
and
Understanding Core Data iCloud Store Migration When Testing an iOS App Update
but, actually, I'm very confused.
What's supposed to happen is that iCloud data only syncs between devices that are using the same version of the data model. If you upgrade the app on one device but not on a second device, they won't sync changes until the second device also updates to the new model version.
If that's not what you're seeing, please add more details about the problem you're seeing.

how i can avoid my data lost when i updates my apps in iOS?

When using PhoneGap, do users lose all of their saved data when they update an iOS app downloaded from iTunes?
I am hoping that anything stored in either Webstorage feature in Construct 2 will be preserved whenever someone downloads a new version of the app from iTunes, but I'm afraid to build a whole Apps only to have a bunch of upset users when they update the app. I know when I build an app in Objective C I have to go through some hoops to get the Core Data store to migrate correctly.
The other option is to mirror the data to an external server/database, but I want to avoid that expense and complication if I can.
If you change anything in the tables in CoreData then you would have to implement migration for the tables by creating a new version (check apple's documentation here: Lightweight Migration)
Otherwise if you don't change anything updating the app would not make the user lose any data.

ios how to manage DB with iphone app version by version?

My question contains two ways:
1. For example I have an app which is on appstore and containing sqlite database. After sometime I want to update app version without changing database schema. what happened when app will be updated on user's device ? would all data in old database removed or just remains with same database and data ?
2.For example I have an app which is on appstore and containing sqlite database. After sometime I want to update app version with changed database schema. what happened when app will be updated on user's device ? its must changed the DB file but how can we save old data entries those are in old DB version. I have read many posts but still confused which approach I should use.
Thanks in advance for Helping
It is quite simple. When updating the application documents folder remains intact, so you can assume that the user data continues to be available.
For case 2 make sure you do not compromise the data in your update routines at the first start after the update. The app should detect that it is in a new version and modify the schema (e.g. via SQL scripts) while taking care of not deleting user data.

Updating an ios app that uses coredata with a version without

We are planning to update an iOS app that currently uses coredata with a complete rebuild that isn't using coredata. If the schema is not present in the update bundle will it crash on existing users devices?
This is hard to test but I'm guessing as the schema is associated with the app it will need to be present even if it isn't going to be used.
Anyone had experience with doing something like this?
The data model (what I'm assuming you're calling the schema) is only needed in app if you're building a Core Data stack. It can be removed if you're not building one.
You're app should still be using Core Data for the time being though. You're going to want to build the Core Data stack to use it to read in the user's existing data for migration. So if that's the case, don't go deleting it from the app yet.

Resources