Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iCloud Exception - Error importing transaction log

I am trying to integrate iCloud into one of my iOS apps. At first everything works fine but every know and then iCloud stops working and the app crashes. There seems to some problem with the transaction logs but I cannot figure out concrete source. Trying to catch the exception is also not possible.

This is the console output iCloud creates:

2014-02-07 10:23:45.118 MyApp[1410:3707] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity:  mobile~5508B01E-F77F-4AF1-88DE-2E2F8DC55932:MyAppCloudDB
Using local storage: 1

2014-02-07 10:23:45.892 MyApp[1410:3707] -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity:  mobile~5508B01E-F77F-4AF1-88DE-2E2F8DC55932:MyAppCloudDB
Using local storage: 0

2014-02-07 10:24:28.632 MyApp[1410:1803] -[_PFUbiquityRecordImportOperation main](731): CoreData: Ubiquity:  Error importing transaction log: <PFUbiquityTransactionLog: 0x16177920>
transactionLogLocation: <PFUbiquityLocation: 0x160c3e80>: /var/mobile/Library/Mobile Documents/M889WYL2LY~com~example~MyApp/MyAppTransactionLogs/User~37B9682D-CED2-5F79-AF06-1FE99E7DEE9E/MyAppCloudDB/SZPp~RKudtVxEBMJzTVTupTv0WjG6i~o9Vj54dlknjc=/8AB09D17-5856-49B9-BE4C-A56451FB1EF4.1.cdt
transactionNumber: 34
, exception: *** setObjectForKey: key cannot be nil
User Info: (null)

2014-02-07 10:24:28.661 MyApp[1410:1803] -[_PFUbiquityRecordsImporter operation:failedWithError:](1003): CoreData: Ubiquity:  Import operation encountered an error: Error Domain=NSCocoaErrorDomain Code=134060 "The operation couldn’t be completed. (Cocoa error 134060.)" UserInfo=0x162a8b20 {exception=*** setObjectForKey: key cannot be nil}
userInfo: {
exception = "*** setObjectForKey: key cannot be nil";
}. While trying to import the log file at the URL: <PFUbiquityTransactionLog: 0x16177920>
transactionLogLocation: <PFUbiquityLocation: 0x160c3e80>: /var/mobile/Library/Mobile Documents/M889WYL2LY~com~example~MyApp/MyAppTransactionLogs/User~37B9682D-CED2-5F79-AF06-1FE99E7DEE9E/MyAppCloudDB/SZPp~RKudtVxEBMJzTVTupTv0WjG6i~o9Vj54dlknjc=/8AB09D17-5856-49B9-BE4C-A56451FB1EF4.1.cdt
transactionNumber: 34

2014-02-07 10:24:28.686 MyApp[1410:1803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
*** First throw call stack:

(0x30b47e83 0x3aea46c7 0x30a82ecb 0x309dd0cb 0x3099f061 0x309a1841 0x31476aa5 0x3151a96d 0x3b38de7b 0x3b38af93 0x3b38e745 0x3b38e9c5 0x3b4b8dff 0x3b4b8cc4)
libc++abi.dylib: terminating with uncaught exception of type NSException

Does anyone know how to solve this issue?

like image 767
Andrei Herford Avatar asked Oct 01 '22 16:10

Andrei Herford


2 Answers

inspired by berecs comment to my questions I want to share the solution that worked for me:

Stop using iCloud! Now! Just drop it! Stop wasting your time with it do something productive.

I started to support iCloud 2012, not long after it was launched. In fact the integration of iCloud into may app was quite easy and during my tests everything worked fine. Not long after I released the first version supporting iCloud I received the first user complains about strange error, crashes, start up problems, etc.

Of course I thought that I made some mistake, that my implementation would be buggy and that I could solve the problem with some bug fixes. That was not the case.

iCloud is just like a sinking boat with a thousand leaks. As soon as you have fixed a couple of issues and think that everything should work fine now the next problem arises.

Soon I realized that not my iCloud implementation was the problem but iCloud it self. It just does not work. I jused it to sync my Core Data stack and it was hell. Maybe it works better when working with Documents or simple Key Value Pairs but iCloud + Core Data is an impossible combination.

80% of my support work was due to iCloud related questions. Of course users said "It is your fault, other apps use iCloud without any problem" but this obviously not true. Thus is is just a matter of time before your app will get a large number of bad reviews just because iCloud.

Last year I removed iCloud support from my app and added support for other sync services like Dropbox and Google Drive. Of course this is not a 1 to 1 replacement for iCloud (no live sync, etc) but at least these services work!

So the best solution to get rid of these strange iCloud problems: Get rid of iCloud!

I tried everything to get it working and spend

like image 78
Andrei Herford Avatar answered Oct 13 '22 10:10

Andrei Herford


These are internal iCloud exceptions and unfortunately there's nothing you can do about them. You can't catch them, and even if you did, there's no way for you to handle them. iCloud is opaque enough that when it goes wrong, you're just stuck.

The one thing that's likely to help, significantly: If you are still supporting iOS 6 or iOS 5 in this app, stop now. At least don't support iCloud when running on those versions. On iOS 7 iCloud is much improved, and while not perfect is less likely to have this kind of trouble.

like image 20
Tom Harrington Avatar answered Oct 13 '22 12:10

Tom Harrington