Articles and podcasts about Swift development, by John Sundell.

Genius Scan SDK

Presented by the Genius Scan SDK

This article has been archived, as it was published several years ago, so some of its information might now be outdated. For more recent articles, please visit the main article feed.

Improved compiler errors for auto-synthesized conformances in Xcode 11

Published on 25 Jun 2019
Discover page available: Codable

New in Xcode 11/Swift 5.1: The compiler will now tell you why it can't auto-synthesize conformance to protocols like Encodable and Decodable, instead of just suggesting a manual implementation. Let’s say we have the following type, that we wish to conform to Decodable automatically:

struct ItemMetadata: Decodable {
    var date: Date
    var format: ItemFormat
    var category: String
}

If the ItemFormat type used above isn’t Decodable, then the compiler will now give us the following error:

Cannot automatically synthesize 'Decodable' because 'ItemFormat'
does not conform to Decodable.
Genius Scan SDK

Swift by Sundell is brought to you by the Genius Scan SDK — Add a powerful document scanner to any mobile app, and turn scans into high-quality PDFs with one line of code. Try it today.