I am adding iCloud with Core Data to an app that already exists in the app store, so I need to test upgrade scenarios. However, when I delete my app from my device and re-install it from Xcode, I have noticed that everything inside of my ubiquity container folder on the device is persisted! This is incredibly annoying, as iCloud ends up getting confused when trying to upload files from the transaction logs directory I have specified and often times out. I end up needing to specify a new transaction log location to get it to work again, which will obviously not work in the future for my testing.
The following is the error I receive:
PFUbiquitySafeSaveFile waitForFileToUpload:: CoreData: Ubiquity: (0) permanentLocation: : /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~appnamegoeshere/DatabaseTransactionLogs/mobile.8A0C3F8A-4077-57D7-8250-6BE15D1BCD20/iCloudData/8u0BfiCwOkHHa~o8hF4bunW~zmdS_C8om5efuugxRaA=/receipt.0.cdt safeLocation: : /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~appnamegoeshere/DatabaseTransactionLogs/mobile.8A0C3F8A-4077-57D7-8250-6BE15D1BCD20/iCloudData/8u0BfiCwOkHHa~o8hF4bunW~zmdS_C8om5efuugxRaA=/mobile.8A0C3F8A-4077-57D7-8250-6BE15D1BCD20.0.cdt currentLocation: : /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~appnamegoeshere/DatabaseTransactionLogs/mobile.8A0C3F8A-4077-57D7-8250-6BE15D1BCD20/iCloudData/8u0BfiCwOkHHa~o8hF4bunW~zmdS_C8om5efuugxRaA=/mobile.8A0C3F8A-4077-57D7-8250-6BE15D1BCD20.0.cdt
kv: (null)
Safe save failed for file, error: Error Domain=NSCocoaErrorDomain Code=512 "The file upload timed out." UserInfo=0x1e5b6b10 {NSLocalizedDescription=The file upload timed out.}
Does anyone know how to clear out a ubiquity container between app installs? Even removing the ubiquity container from the app settings and republishing it does not fix this issue. A customer in theory would be able to hit this issue just by deleting the app and then deleting their iCloud files for it. This issue has been really frustrating to determine what the cause of the issue is - any suggestions are appreciated!
After much head pounding, I was able to figured this out. Someone mentioned to me that you are able to see all of your iCloud data for your device if you go to developer.icloud.com and login with your iCloud account. Doing some tests with this, I was able to see that the data on the iCloud server was being deleted immediately when I told it to delete from my device. However, all of the folders and files I had created in my ubiquity container on my device stayed, even if I deleted my app.
My work around was to check when setting up my app for using iCloud for the first time and see if my directories were already in the ubiquity container. If they were, then I manually delete the directories and all of the files in them with the following code:
[fileManager removeItemAtPath:[[fileManager URLForUbiquityContainerIdentifier:nil] path] error:&error];
This is how iCloud is supposed to to work. Deleting an app on one device doesn't automatically delete the iCloud data. If the app is still installed on other devices that use the same account, they can still use the data.
If you want to clear out iCloud data during testing, go to Settings --> iCloud, drill down to your app, and delete the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With