Since you haven't included the compilation error, I pasted your code snippet into a new CoreData mac project. First issue seems to be the way you have declared the FetchedResults, but perhaps that is just a typo or forum display issue. This is what you want
@FetchRequest(entity: Account.entity(), sortDescriptors: []) var account: FetchedResults<Account>
Or you can drop the entity parameter if you want, since it can be automatically inferred for you
@FetchRequest(sortDescriptors: []) var account: FetchedResults<Account>
If you are autogenerating the Swift classes for your model entities, sometimes Xcode will be confused and report "Use of undeclared type" but the issue normally resolves with a clean build, ensuring that your classes are regenerated. If not, try switching to manually creating and adding the NSManagedObject subclasses for your entities.
Finally there is one runtime gotcha that might be the actual problem you are referring to since you mention that your project works on iOS. If you launch the application and you see this type of log message
[error] error: No NSEntityDescriptions in any model claim the NSManagedObject subclass 'Account' so +entity
is confused. Have you loaded your NSManagedObjectModel yet ?
This is a problem in the Xcode SwiftUI CoreData project template for mac, where the SwiftUI view gets created before the model has been loaded. This is due to the persistentContainer, which will load the model, being a lazy property of the app delegate meaning that it's not created until first accessed. Easiest fix if you want to keep it lazy is to split up this part
// Create the SwiftUI view and set the context as the value for the managedObjectContext environment keyPath.
// Add `@Environment(\.managedObjectContext)` in the views that will need the context.
let contentView = ContentView().environment(\.managedObjectContext, persistentContainer.viewContext)
into
// Create the SwiftUI view and set the context as the value for the managedObjectContext environment keyPath.
// Add `@Environment(\.managedObjectContext)` in the views that will need the context.
let context = persistentContainer.viewContext
let contentView = ContentView().environment(\.managedObjectContext, context)
which will ensure that the model is loaded before the view is created, and is similar to what the iOS project template looks like which might explain the different experience