Post

Replies

Boosts

Views

Activity

Xcode 16.0. SwiftData Schema Fatal error: Inverse already set to another relationship
Hi, after upgrading to Xcode 16.0 I encountered the fact that when loading preview, I get an error: Fatal error: Inverse already set to another relationship - secondAccount - cannot assign to - firstAccount import Foundation import SwiftData import SwiftUI @Model class TransactionModel { @Relationship(inverse: \AccountModel.accountTransactions) var firstAccount: AccountModel? /// <- here @Relationship(inverse: \AccountModel.accountTransactions) var secondAccount: AccountModel? /// <- here @Relationship(inverse: \DebtorModel.transactions) var debtor: DebtorModel? @Relationship(inverse: \CategoryModel.transactions) var category: CategoryModel? init(account: AccountModel? = nil, secondAccount: AccountModel? = nil, debtor: DebtorModel? = nil, category: CategoryModel? = nil) { self.firstAccount = account self.secondAccount = secondAccount self.debtor = debtor self.category = category } } import SwiftData import SwiftUI @Model final public class AccountModel: Identifiable, Hashable { var accountId: UUID = UUID() var accountTransactions: [TransactionModel]? init(id: UUID = UUID()) { self.accountId = id } } Is this really not possible to implement? In Xcode 15, this worked both on the device and in the editor. Thanks!
1
0
405
Sep ’24