'Transaction' is ambiguous for type lookup in this context - SwiftUI

I'm developing a SwiftUI multi-platform, multi-user app for family budget management (not for the App Store) using CoreData and iCloud with NSPersistentCloudKitContainer.

I use manual Codegen in Xcode to generate the CoreData entity classes, then add extensions for computed properties. These are in my DataModel (ViewModel), which is in an included framework. All data processing is done in the data model.

All's working fine in the SwiftUI Views, except for one entity - 'Transaction', which throws a compiler error "'Transaction' is ambiguous for type lookup in this context". Some SO posts say to use the App Name as a prefix to the type, but this doesn't work.

What does solve it, in this case, is to use the name of the Framework (Library) holding the type definition:

import SwiftUI
import OurMoneyLib // my framework holding the DataModel and CoreData entity classes

struct TransactionRow: View {
    let appAPI = AppAPI()
    var transaction : OurMoneyLib.Transaction
var body: some View { ......

Why this one entity throws an error, I know not - but it's fixed!

I hope this helps someone, somewhere, sometime.

Cheers, Michaela

Ah, I've just discovered why my Transaction entity was giving problems: SwiftUI uses a Transaction struct to pass an animation between views in a view hierarchy. It's too late to change my entity name, and the above mentioned solution works anyway.

Cheers, Michaela

'Transaction' is ambiguous for type lookup in this context - SwiftUI
 
 
Q