"/assets/images/2020/12/unsupported-kvc-aggregate-in-keypath.png", "title"=>"Xcode asset catalog screenshot", "caption"=>"I ran into a cryptic error with only two ten-year-old hits on Google."}">

Unsupported KVC in Keypath

24 Dec 2020

I ran into a cryptic error with only two ten-year-old hits on Google. Here's why.

Yesterday, I ran into a cryptic error message in Xcode, and there were only two ten-year-old hits on Google.

Unsupported KVC aggregate in keypath

So, in case future you runs into this problem, here’s another, different cause.

The short version was that I was trying to do an NSPredicate comparison for Core Data, meaning ==, and I’d accidentally typed = instead. I’d been working in SQL earlier in the day where = is used as a comparison operator, so an easy mistake to make in context.

So:

let predicate = NSPredicate(format: "id = %i", buildingData.id)

…instead of:

let predicate = NSPredicate(format: "id == %i", buildingData.id)

It was initially confusing because I wasn’t specifically trying to aggregate anything, but Xcode was clearly confused about what, exactly, I was trying to do.

Hope this helps!