6

I have just one iOS device at the moment, and it hasn't been a problem so far. But I now want to add iCloud sync support to my app (which uses Core Data).

Will testing be simply impossible until I get a second device? Or is it possible to use iOS Simulator in conjunction with my device or to fake iCloud data in order to test iCloud sync?

Edit: It doesn't take much research to find that iCloud, especially with Core Data, definitely requires extensive testing and that certainly means testing with more than one device!

Clafou
  • 15,250
  • 7
  • 58
  • 89
  • 3
    http://developer.icloud.com/ allows you to view what you've synced up to iCloud. – jrtc27 Sep 09 '12 at 09:20
  • 1
    So far, the simulator cannot be used for iCloud testing. Hopefully Apple will allow that at some point. You can view what you have synced accessing "~/Library/Mobile Documents" on your Mac, given you have configured the same iCloud account on it. – Jorge Sep 12 '12 at 16:10

3 Answers3

6

In Xcode 5:

OS Simulator now supports iCloud syncing of documents and KVS data within an app, enabling apps to sync between devices using iCloud. This feature is useful when testing to ensure that the app documents and data are syncing properly across multiple devices.

Note: With the app running in the iOS Simulator, sign in to an Apple ID account using the Settings app. After signing in, use the “Trigger iCloud sync” command in the Debug menu to tell the simulator to sync with other devices.

sash
  • 8,423
  • 5
  • 63
  • 74
  • I recommend running 2 simulator devices at the same time. That way you will be able to visual updates from one device onto the other. See my comment at: http://stackoverflow.com/questions/26446346/xcode6-run-two-instances-of-the-simulator/26446438#comment45601483_26446438 – ObjectiveTC Feb 21 '15 at 22:36
3

You could use your mac as the second device and take the backend of your iOS core data code and write a test app for the mac. You will have to run the app as a sandboxed app in xcode and put the same sandbox name in the app settings for the apps to see each others data.

To make this work you need to create a mac app up on the provisioning portal (requires a mac developer license 99 bucks - cheaper than an iOS device) and enable it for iCloud.

In general unless you are going to try and manage merge conflicts in your app, you dont need to test iCloud itself. Anything that is in the ubiquity container will in fact be synced. If you need transactional control across devices (same documents being updated on multiple devices at the same time for the same user, you would have to handle conflicts), depending on what your app does it might be an issue.

deleted_user
  • 3,817
  • 1
  • 18
  • 27
  • Thanks! I had been thinking about a Mac OS port but I didn't realize it means buying another developer license on top of the iOS one. I've been thinking that I could also simply create a second dummy target of the app with a different App ID (and register it in iTunes Connect to use the same iCloud ID) in order to deploy two separate versions of the app on my iPhone. Then I could test it all on the same device, editing data in the first version and then opening the second version to test sync. – Clafou Sep 16 '12 at 23:34
  • 1
    You could do that but you wouldnt be testing anything. Both apps would be accessing the same ubiquity container on the same device. – deleted_user Sep 17 '12 at 03:05
3

One way you could test at least a sub-set of your syncing is to install your app on your device, add some data, sync that data to iCloud, then delete the app from the device.

When you install it again and sync to iCloud, you should then get back the same data you previously synced up to iCloud.

It's not exactly real-time, but it should give you something to work with.

Freney
  • 1,174
  • 1
  • 11
  • 26
  • Good idea, it's a starting point but I can't release the app without testing what happens when an installation that already has user data is sync'ed through iCloud. – Clafou Sep 16 '12 at 23:40