Grdb.swift: Xcode 12 error: "Cannot find 'CodingKeys' in scope"

Created on 3 Jul 2020  路  10Comments  路  Source: groue/GRDB.swift

This error is a compiler bug: https://bugs.swift.org/browse/SR-13137 (please click the link and vote in order to help having it fixed).

It happens when a Column defined by one record type is used in another file.

A workaround is to prepend CodingKeys with the name of the record:

 struct Player: Codable {
     var score: Int
     ...
 }
 extension Player: FetchableRecord {
     enum Columns {
-        static let score = Column(CodingKeys.score)
+        // TODO: remove `Player.` prefix when SR-13137 is solved
+        static let score = Column(Player.CodingKeys.score)
     }
 }
support

Most helpful comment

Xcode version 12.2 beta (12B5018i) has fixed the issue 馃檪

All 10 comments

@groue voted! I'm also noticing segfaults with enums that rely on automatic String conversion.

What do you mean @vmanot? Do you have any information or code to share regarding those enums? It's impossible to guess with your first message.

@groue I should've been more clear, my comment was about Swift 5.3 and nothing specific to GRDB. I'm noticing simple enums such as the following:

enum Foo: String {
    case bar
    case baz
}

Cause segfaults in Swift 5.3 (as of Xcode12b5), in moderately complex and large codebases.

I just wanted to know whether you've experienced issues of the same sort. It's not a problem with GRDB.

All right, thanks for the details. No I haven't met such issue with the Swift 5.3 compiler yet!

The fix https://github.com/apple/swift/pull/33586 was merged into the Swift 5.3 compiler. Xcode 12 beta 6 does not include it yet. Let's wait for the next Xcode release.

Xcode聽version 12.0 (12A7209)聽wasn't shipped with the fix :-/

Xcode version 12.2 beta (12B5018i) has fixed the issue 馃檪

Perhaps worth noting that while you can submit apps to Testflight with the beta Xcode, you can only submit apps for App Store release with the public (GM) Xcode.

Xcode 12.2 has shipped, I can close this issue.

For me it was the target check.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndreYonadam picture AndreYonadam  路  4Comments

mtancock picture mtancock  路  3Comments

wyattbeavers picture wyattbeavers  路  3Comments

chiliec picture chiliec  路  7Comments

Mina-R-Meshriky picture Mina-R-Meshriky  路  7Comments