I'm trying to add iCloud support to my app and have two devices for testing, an iPhone and an iPad. Both are running iOS 8.1 and are connected to the same Apple account. When I check the Settings for iCloud, I can see that other apps are successfully using iCloud on both devices. However, while on the iPhone everything works ok (i.e. I get the "Using local storage: 0" message shortly after starting the app), on the iPad it crashes with:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
Turns out [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier : nil]
returns nil
. What could be the cause of this behaviour considering that I'm running the exact same build on both devices, so there are no differences in any configurations, entitlements, etc.
EDIT
Actually, seems iCloud is in general unavailable on the iPad. [NSFileManager defaultManager].ubiquityIdentityToken
returns nil
as well, and that should be a fairly reliable way to figure out if the iCloud can be used or not. :(
The iCloud sync daemons seem somewhat flaky still on iOS 8.1. On devices that are having problems use the settings app to sign out of that iCloud account, and sign in again. Reboot the device for good measure and try again. Repeat if necessary.
This normally clears any iCloud weirdness for me...
Other than that, are your iCloud entitlements configured correctly? Check both Xcode Capabilities and Certificates & Identifiers on the Dev Centre website and see that both think these are ok. If other apps on the affected device are able to sync documents (via Documents & Data OR iCloud Drive) then it's probably your config.
Also, don't rely on Settings telling you other apps are able to sync documents - are those apps ACTUALLY syncing documents (so create documents in the apps and see if they actually sync)... What Settings says does not always reflect what the underlying daemon processes are actually doing.