Search code examples
iosobjective-ccore-datarelationshipsimperium

Simperium iOS CoreData Relationships Randomly Null


I am currently having an issue with Simperium on iOS with CoreData. Upon launching the app for the first time, Simperium tries to sync with CoreData.

Sometimes it will work 100% correctly, and other times it will set some of the relationships to "nil" despite the Simperium data on the server NOT saying that. This is then NEVER fixed unless I re-install the entire application. And then I roll the dice again to see if the relationships are linked properly on startup.

I cannot find a pattern in this. The relationships that are nil are completely random. Sometimes this entity over here will have nil relationships, and then the next time I try it a different entity will have nil relationships.

All relationships are optional and there is nothing wrong with my CoreData file.

Has anybody had an issue like this? I found the exact same issue in a bug from 2014, but it's been forever since then.

Exact same issue I am having can be found here: https://github.com/Simperium/simperium-ios/issues/250

Side Note: If you read that issue, he also clarifies that he has a problem with editing the CD file WHILE Simperium is syncing, causing nil relationships. Has anybody confirmed this happening? If so this might be my problem.


Solution

  • It's highly likely that this glitch is caused by the scenario you've described (editing the CD file while Simperium is Sync'ing).

    Core Data deals, internally, with locks to maintain data integrity. Accessing the sql storage directly might result in data corruption (i'm assuming you're editing the file via either a Firefox plugin, in the simulator, or accessing the file via a Filesystem API).

    Please, try to reproduce the issue without accessing the Core Data's sqlite file directly (always go thru NSPersistentStoreCoordinator / NSManagedObjectContext).

    If you do succeed, and there's effectively a bug, we'd love to get it fixed! (In which case, please, open an issue the main repository, including as many details as possible).

    Thanks for your interest in Simperium!