Testing iCloud sync with a single iOS device - ios

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!

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.

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.

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.

Related

iCloud & iCloud Drive saving core data multiple devices with and without iOS 9

I have searched and searched but it is not entirely clear, I haven't programmed much in years, I have to update an old app for a client that will be using iPods iOS 6 and new iPhones with iOS 9 logged into the same iCloud account.
Will changes to core data of app on an iOS 6 device update content for the iOS 9 device?
I have not experienced problems with updates to iCloud in NSSUserDefaults when testing on iOS 6 and ios9 devices (with iCloud drive disabled)
I cannot get iCloud for core data to work on ios9 iCloud drive disabled, so I need to update to iCloud Drive... But I am worried about data on other devices not updated. Debugging nightmare?
Core Data with iCloud is really flaky, I really don't recommend it.
Devices that have switched to iCloud Drive will make changes that won't be visible to those that haven't (including those devices that don't support it, most definitely those running iOS 6). Not sure about the opposite, but it's probably the case as well.

How to retrieve data from iCloud Production environment

Is there a way to access data from iCloud production environment through iOS simulator? Because I need to retrieve an application data to analyze them, so if I could do it from simulator it will be easier to me.
If it's not possible to access with simulator, Could you give me an idea to do it with iPhone?
The easiest way is to archive your app and distribute it using testflight. An app distributed with tesflight is always linked to the production database. As far as I know there is no way to connect to the production database from the simulator or while debugging.

Existing iOS 7 and iOS 8 Apps with Core Data and iCloud, but not with iCloud Drive

I have an existing app in the App Store which uses Core Data and iCloud as a mechanism for storing information locally on users' devices and synchronising across to other devices.
The app works really well on iOS 7 and iOS 8 with the iCloud functionality. I have not done any work to update my app for "iCloud Drive" though because it doesn't seem like what my app requires.
If I enable iCloud Drive on my phone and Macbook Pro, will that have any impact on the iCloud data? What I mean by this is, if iCloud Drive is enabled, what happens to the apps that use iCloud standard? I'm asking because I want to prepare my users before they upgrade to iCloud Drive.

NSFileManager ubiquityIdentityToken returns nil unexpectedly?

I am using this iCloud library within my application: https://github.com/iRareMedia/iCloudDocumentSync
On my iPhone running iOS 8, I run the app and ubiquityIdentityToken returns a value and everything works fine. However on my iPad running iOS 7.0.4, it returns nil.
I ensured a few things on the iPad:
The iPad is connected to wifi and can connect to the internet fine
iCloud is in fact set up on the iPad. I can see this because it says so in Settings and iCloud tabs are working in Safari.
The documents and data option is in fact enabled
Xcode set up iCloud automatically via the capabilities iCloud tab and it works on my iPhone with the same set up.
Is there any reason why this could be happening? It seems hard to believe that it can work on one device and not the next. Any help would be appreciated.
I'm not sure if this is your problem, but Apple does mention in What's New in iOS 8 that a user's iCloud data in iOS 8 is incompatible with iOS 7:
"The iCloud infrastructure is more robust and reliable when documents and data are transferred between user devices and the server. When a user installs iOS 8 and logs into the device with an iCloud account, the iCloud server performs a one-time migration of the documents and data in that user’s account. This migration involves copying the documents and data to a new version of the app’s container directory. This new container is accessible only to devices running iOS 8 or OS X v10.10. Devices running older operating systems will continue to have access to the original container, but changes made in that container will not appear in the new container and vice versa."
Edit:
To see if this is your problem, you should test on two iOS 8 devices and compare to two iOS 7 devices. If you are still running into the same issue on the same versions of iOS there is something else going on as well.
I know iOS 8 is still under NDA so this answer can't be as specific here as I would like it to be but I'll just say the following. This answer: https://stackoverflow.com/a/24584019/394736 points to this link: https://devforums.apple.com/thread/229509 and that fixed it for me on both iOS 7 and iOS 8 devices!

What is Sandbox in iOS? Can I transfer data between one app to another app?

Is there anything like sandboxing an iPhone Application, what are the benefits on using sandboxes and do they allow me sharing data between one app and another?
I found this link while searching but not able to understand as I'm new to iOS development.
http://www.iphonedevsdk.com/forum/iphone-sdk-development/56207-what-is-sandbox-in-iphone.html
From The iOS Environment
For security reasons, iOS places each app (including its preferences
and data) in a sandbox at install time. A sandbox is a set of
fine-grained controls that limit the app’s access to files,
preferences, network resources, hardware, and so on. As part of the
sandboxing process, the system installs each app in its own sandbox
directory, which acts as the home for the app and its data.
one solution to transmit data from one to another app is via URL Schemes
Mobile device application developers use the sandboxing capability of iOS to ensure the security of the user data and to ensure that the application don't share data with other applications installed on the same device.
The sandbox forms and maintains a private environment of data and information for each app.
The sandbox can minimize the damage that can be done from a potential hacker but it can't prevent the attack from happening.
Although Apple has built robust sandboxing features into iOS , it is upto the developer's to ensure that their apps are written securely.
When an app is installed on a mobile device, the system creates a unique directory for it.
Sandboxing only prevents the hijacked app from affecting the other apps and also other parts of the system.
iPhone apps are all sandboxed, meaning there is no sharing of files between applications.
There are some ways of transferring data between applications but they're very limited. Look at URL schemes.
http://wiki.akosma.com/IPhone_URL_Schemes
The apps are in sandbox by default. You do not need to worry about putting it in a sandbox manually.

Resources