Cannot find type 'KeyPathComparator' in scope

I'm working on what is essentially a "Hello World" app from the developer's conference. (Garden App)

I'm trying to get the Automatic preview working, but I get "Automatic preview updating paused".

I'm getting a bunch of errors, "Cannot find type 'KeyPathComparator' in scope. And a bunch of similar.

Could someone please help?

Make sure you are launching Xcode-beta (Xcode 13) and not the old Xcode. It builds for me in Xcode 13 but has a similar error to yours in Xcode 12.5

You've not really identified the context in which the error is appearing, however I can suggest that if it is relation to sorting, then you should replace KeyPathComparator with SortDescriptor.

For example... this doesn't work...

    @State var sortOrder: [KeyPathComparator<ModelObject>] = [
        .init(\.dateCommences, order: SortOrder.forward)
    ]

... however this does...

    @State var sortOrder: [SortDescriptor<ModelObject>] = [
        .init(\.dateCommences, order: SortOrder.forward)
    ]

where dateCommences is an example property of ModelObject.

I am getting this very same error on a Xcode 13 version while neither importing foundation nor replacing with SortDescriptor works.

Cannot find type 'KeyPathComparator' in scope
 
 
Q