Daily iOS
Concurrency

Swift 6 singleton build

The take-home app you submitted has a singleton ImageCache created with static let shared (with var storage: [URL: UIImage] inside) that several screens read and write from background queues. The interviewer asks: "What happens if you build this project in Swift 6 language mode?"

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Swift 6 strict concurrency rejects a static let shared of a non-Sendable type with a 'not concurrency-safe' compile error. A class holding a mutable dictionary isn't Sendable, so the build breaks, and a latent data race surfaces at compile time.

Share a question