Skip to content

Instantly share code, notes, and snippets.

@juanarzola
Last active November 16, 2025 02:55
Show Gist options
  • Select an option

  • Save juanarzola/c5c2268b88840ec4bc6f0be2a053b2bb to your computer and use it in GitHub Desktop.

Select an option

Save juanarzola/c5c2268b88840ec4bc6f0be2a053b2bb to your computer and use it in GitHub Desktop.
An extension that normally works, except from shortcuts, where uuid isn't found in the schema
extension FetchDescriptor {
public static func model<Model: PersistentModel & UUIDString>(
withUUIDString uuidString: String?
) -> FetchDescriptor<Model> {
guard let uuidString else { return .init(predicate: .false) }
let pred = #Predicate<Model> { $0.uuid == uuidString }
var desc = FetchDescriptor<Model>(predicate: pred)
desc.fetchLimit = 1
return desc
}
}
@juanarzola
Copy link
Author

juanarzola commented Nov 16, 2025

Error (on AppIntents, running on Release):

Task 1887: Fatal error: Couldn't find \Item.<computed 0x000000010348f1b8 (String)> on Item with fields [SwiftData.Schema.PropertyMetadata(name: "uuid", keypath: \Item.<computed 0x0000000103523cfc (String)>, defaultValue: Optional("9EF6CEAF-2328-46E9-99FF-0FF1F0AC9C14"), metadata: nil), SwiftData.Schema.PropertyMetadata(name: "itemTypeRaw", keypath: \Item.<computed 0x0000000103508c40 (Int)>, defaultValue: Optional(0), metadata: nil), SwiftData.Schema.PropertyMetadata(name: "card", keypath: \Item.<computed 0x0000000103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment