Member-only story
CloudKit, Sharing and Concurrency
A Trials of getting some WWDC2021 code running…
I published several articles on the new concurrency language features in Swift 5.5, papers you can find here, here, and here.
But looking through the frameworks that Apple updated, an unusual one caught my attention — CloudKit. With another change to the said framework that also looked interesting, more sharing.
I noted that some demo code illustrated how it worked, so I downloaded it, but was in for a surprise. Of course, it has been six months since the WWDC2021 and it didn’t work. Join me to try and figure out how to fix it.
- Look for “apple” in the CloudKit reference, replace it with your domain, and reset the app’s signing.
- Sign in to the simulator through settings if needed.
- Fix syntax line 94 & line 172
_ = try await database.modifyRecords(saving: [contact.associatedRecord, share], deleting: [])
- replace async with Task line 30, 35, 37, 41, 116
- replace spawn with addTask line 140
Now, refresh throws an error if your database contains no contacts, so I changed func refresh to return an empty set. I then tried to add a contact to the database via the menu — although sadly, the…