Thursday, April 20, 2023



A library that helps you isolate CloudKit dependency and write testable code using CloudKit.


In live use of your app, you initiate and inject the live Canopy object that talks to CloudKit. When independently testing your features, you instead inject a mock Canopy object that doesn’t talk to any cloud services, but instead plays back mock responses.

Jaanus Kase:

There’s still not a whole lot written about CloudKit. It continues to be this mysterious thing and I think it’s underused.

As part of Canopy, I publish a documentation site that covers not only the library, but also some broader topics around CloudKit, such as its tradeoffs, how iCloud Advanced Data Protection affects your apps, etc.

See also: Dependencies.


Update (2023-06-02): Jaanus Kase:

I greatly enjoyed putting the whole package together. For better or worse, it reflects my shape as a maker of things on Apple platforms as of early 2023. In the spirit of testable code, Canopy itself is well tested, and the important parts have 100% or near-100% test coverage. I’m pretty happy to see this coverage.


One compromise I chose to make is that Canopy produces a number of warnings with Xcode 14.3. Halfway working through Canopy, Apple shipped Xcode 14.3 with Swift 5.8 that enables Sendable warnings for many Apple system types, including CloudKit types like CKRecord. Canopy does indeed ship these types across actor boundaries, which currently produces warnings like this.

Comments RSS · Twitter · Mastodon

Leave a Comment