Do files in NSDocumentDirectory transfer when user upgrades iPhone - ios

I have an app that saves user entered information to the NSDocumentDirectory. On issue that people are having is when they upgrade their iPhone to iPhone 5, the information in their old NSDocumentsDirectory are not being transferred over, even when they select the app to be transferred over.
Users end up loosing all their entered data when they upgrade.
When users upgrade the app on the same phone they do not lose their data. It only happens when they upgrade to a new iPhone.
What is the way to correctly save User data and make sure it is transferred over when the phone is upgraded?

Data is only transferred to a new device if they choose to do a full backup of the old device and then choose to restore that full backup to their new device. Simply transferring apps results in fresh installs of the apps with no data.
This has always been a major problem with iTunes (and now iCloud backups). There is no way to backup a single app and its data and there is no way to restore a single app and its data. Only the app can be restored but no data unless a full device restore is done.
All of my apps have their own built-in features for backing up and restoring its own data. This allows users to easily transfer data between devices or deal with them messing up their own data by mistake.

Related

How to export Core Data sqlite to iCloud and import back for new devices

I'm developing core data based app and want to implement iCloud so that user can recover data from iCloud if he lost device and bought new one.
I enabled iCloud capability and iCloud documents(I'm currently using NSPersistentContainer, I don't want to use NSPersistentCloudKitContainer yet)
I know iOS 13 provides way to sync Core Data with iCloud but I think that doesn't seem to be ready for production app yet(Migration doesn't work well)
So I want to back up core data to iCloud every 24 horus to iCloud and when user installs app in new device we can check if iCloud has existing sqlite file and restore it if there is any.
Could anyone please suggest good solution?
Thanks.

What happens to local Realm DB when app is auto offloaded by iOS for lack of recent usage?

In iOS 11, unused apps have the potential to be automatically removed by the operating system to conserve disk space.
This is hard to test because I would need to let an app in development sit unused on a device for an extended period of time.
No similar questions were found online or addressed in relevant documentation.
What will happen to any application data persisted in a Realm DB? From the OS point of view are any underlying data saved such as a Realm DB?
The idea of the app offload feature is that the app itself is removed whilst any data is left in situ. The option on iPad settings specifically states that "Your documents and data will be saved". If you look under storage for your app on an installed device, it will differentiate between "App size" and "Documents & Data", so only "App size" should be recovered by offloading.
If you have the app already published in the app store and installed on a device then you can test this (not sure if it works under TestFlight). Under the Settings -> iPhone/iPad Storage, if you select the app then you have the option to Offload the app manually. Opening the app redownloaded it from the app store, and my data was still available from the realm storage before the data refreshed.

Save my app data through phone restore - iOS Swift

What technology is available for me to save app data (Core Data) so that when a user switched phones and has a fresh phone they still have my app information?
I have heard people say cloudKit, however that seems overkill, I don't want the functionality to handoff between devices. I simply want the app data to be backed up when the user has iCloud backup enabled for the app.
If the answer is iCloud, what steps must I follow to enable such behavior? I have seen links to cloudKit tutorials, however all of them cover an extensive amount of material and work, and what I want to achieve seems simple enough. (As stated before I do not want handoff between devices, I have no need for it.).
Thank you for the suggestions
Edit: I have gone into "capabilities" and switched on iCloud. Now in my iPhone settings under iCloud backup my app appears. However does simply switching on iCloud capabilities persist your app data to iCloud Drive or backup?
Ex: Go to Settings -> Account -> iCloud -> Scroll down to iCloud Drive and ensure it is checked. My app shows there, but I haven't included any code to implement this (I simply flipped the switch in capabilities)
So from my current understanding I create Core Data as normal, however I add a listener for an changes/updates/deletes/creation of the persistentStore and upload/update iCloud via document storage when this happens? I was under the impression that iCloud was being depreciated and that only cloudKit will remain?
Edit 3:
iCloud = Depreciated, therefore the one and only solution available is cloudKit.
How does one implement cloudKit to interact correctly with Core Data?
What comes to mind is the following:
- Enable cloudKit
Listen to all changes to persistent Store and reflect these changes in CloudKit (somehow)
On app start check to see if CloudKit matches core data (somehow)
if they are not the same then download cloudKit data and save to core data (somehow)
Please clarify if this is not the correct route to proceed down
What technology is available for me to save app data (Core Data) so that when a user switched phones and has a fresh phone they still have my app information?
There isn't any such problem. I've upgraded devices many times and nothing has ever been lost. When I got a new iPhone last year, and when I got a new iPad this year, all my apps on the new device simply showed up with the same settings and data as before on the old device.
That's the because the user who gets a new device backs up from the old device and restores to the new device. That's what I always do and it just works. You cannot reliably work around a user who is too stupid to know to do that, so I recommend not even thinking about it.

How to test local storage persistence after iOS App Store update?

At one point there was an AIR bug (3.5) that changed the location of the LSO storage, causing local SharedObjects to be "lost" after an app update. Apparently this issue was resolved in 3.6 and life goes on.
At this point I don't have 100% confidence that any user data stored in a SharedObject on an iOS device will persist after an AppStore update, and I would like to be able to test this out prior to actually submitting the update to Apple.
However, my experience has been than whenever you test/debug your app and a new IPA is generated, the old app is completely wiped, including all of its data. So there's no way that I know of that I can test an update of the app against an older version to ensure that the SharedOjbects remain accessible and working fine.
Are there any solutions? Or can anyone who's using LSO for persistent App data storage confirm that they've pushed an update through the App Store and retained saved user data?

IPhone Core Data Backup Restore Testing Questions

I'm in the learning stages of IOS development and have a few questions based on some behavior I recognized on my initial testing.
My questions for now will be related to a local ITunes backup.
For one thing, does an app that is not "certified" (an app under development and testing) supposed to get backed up on ITunes? On ICloud? And what about it's core data? I ask this because I watched as it backed up other apps, but not my test app in the progress bar.
Bottom line is, I want to test how a user of my app's [core] data will or will not be restored under 2 situations as follows.
The user drops his phone in a lake and needs to do a COMPLETE RESTORE on a new device
The user deletes my app (after having backed up), then later wants to reinstall the app.
Through a few different iterations, I can not get my app's data back after an app removal and reinstall.
I would like to test this under both local and ICloud backup. From what I can understand, you are not given the option to see what files/apps are backed up and available to restore. Furthermore you are not able to restore individual apps/data? Or am I missing something?
I have not done anything special in terms of "designing for ICloud backup/restore or syncing". I want all data to be available ONLY locally as it is and is currently working great.
I guess my biggest question for the moment is "Are development apps treated like certified apps in the backup and restore processes?"
There is a lot of information out there but it is all rather convoluted. Plus it appears an ICloud backup/restore and an Itunes backup/restore are 2 different animals? Thanks for any guidance.
BTW, I can see the app in the Backup Options, and Backup? is set to yes, however after I backup and look on ITunes, I see all the other apps except my test app.

Resources