Based on https://github.com/mluisbrown/iCloudCoreDataStack, with some help from Apple Technical support, in Swift language - let's make it better together