How to test restoring an in development iOS app from an iCloud backup?

Is there any methods to test the restoring data of a developmental app that has not been released to App store (either restoring from iCloud or iTunes)?

Replies

There’s no direct way to do this but you do have a couple of options and whether they’ll work for you really depends on what you’re looking to test. Specifically:

  • You can use Xcode’s container support to save and restore your app’s entire container. To save or restore a container, go to the Devices window, select your device in the list on the left, select your app in the Installed Apps list, and then choose Download Container or Replace Container from the gear menu. You can also set up a specific container on each run via the Application Data popup in the Options tab of the scheme editor.

    Note A saved container is just a copy of the directory hierarchy, so you can edit it however you wish.

  • You can back up and restore the device using iTunes. This can either save (if you do an encrypted backup) or not save (otherwise) keychain items, with the latter being more like iCloud Backup.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Regarding the first point, is this how icloud would restore data? i.e. each app container would be stored into icloud and when restoration is required, icloud would download the latest app from the app store and restore/replace each individual app container?

Regarding the first point, is this how icloud would restore data?

I believe so. Regardless, the thing to remember here is that a new version of your app must be able to handle starting up with a container created by an old version. This happens during the normal app upgrade process but there are numerous other situations where you might see this.

Our recently-publish iOS Storage Best Practices video covers this topic explicitly.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

In addition, is this how itune restore data as well? Using this app container?

Restoring a backup via iTunes is not the same as restoring an app container in Xcode. There’s two differences that I can think of:

  • iTunes will restore the keychain, whereas Xcode’s app container support does not affect the keychain in any way.

  • iTunes only backs up a subset of the files in your app’s container (for example, it won’t back up anything in the Cache directory), so only those files get restored.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Has anything changed in the backup / restore in Xcode 9? We've been using this method for a while; but our nightly builds (we've been using Fabric distribution to the team) are no longer showing up in Xcode. Does this only work for builds done directly from Xcode now or do we need to add something in Xcode to make them show up? Same is true for stuff I'm testing installed from Testflight - not showing in Xcode.


Thanks in advance for any light you can shed on this 🙂

Has anything changed in the backup / restore in Xcode 9?

Are you referring to Xcode’s container save and restore feature, as described in my 11 Sep post?

If so, the last thing I can recall changing in this space was a change in iOS 10 (r. 19814108) that prevents full container access from working with Enterprise-signed apps.

I’ve no idea how Fabric works, so I can’t comment on that specifically, but I’d only expect this Xcode feature to work if the app is signed for development (developer certificates and with the

get-task-allow
entitlement).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for your help, what exactly is the difference in the container files between itunes and icloud? (which are not included in itunes? does this affect NSUserdefault?)

I'll forewarn that this is not on the exact topic of the original question. I'm trying to transfer development apps and their data from an old device (iPhone 6) to a new device (iPhone 8), both running iOS 11.2.2. I just tried this container idea, but quickly get an error when I select Download Container:

(Having difficulty getting this image to show up in this forum, so shall link it too). http://cprince.com/AppleForums/XcodeContainerDownload.png

It does create an *.xcapp file/package but it doesn't contain anywhere near all of the data of the app. And the path /Library/Caches/etc. in the error message isn't a path on my system. Looks like just debugging output internal to Xcode.

I have also tried an iTunes backup/restore using iTunes 12.6.3.6, but my development apps are *not* transfered.

Suggestions?


Follow up: I have effectively resolved this. It turns out the iTunes restore restored the data for the app, but not the code/visible part of the app! Once I built the app onto my device using Xcode (same bundle id etc), I had access to the data restored by iTunes. So many hidden things! All's well that ends well?

The error dialog contains two parts:

  • The “file exists” part tells you the actual error

  • The “at” part tells you the location within the Xcode source code where the error was raised

The latter is, alas, not very useful to you.

The only theory I have for why you’d get a “file exists” error is case sensitivity. iOS devices use a case-sensitive file systema while macOS, by default, use a case-insensitive one. If your app’s container includes two items that solely vary by case, I could imagine you hitting an issue like this.

If you use Xcode to browse the container, do you see anything like that?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
It sounds like you solved this issue crspybits? I tried doing what you said, restore and build the device from Xcode. But I do not get the data transferred like you said? Did this change?