@DTS Engineer Thanks a lot for providing the sample, I have tested it out in the sample project and it does work. It works as expected when contained inside a SwiftUI View
. To narrow the problem down it seems that the issue stems from superclass model ID being used inside an @Observable
macro object. For context I have a @Observable
object NavigationStore
that contains state related to navigation such as selection. When specifying an array of Asset.ID inside that I get aforementioned error 'ID' is inaccessible due to '@_spi' protection level
. Expanding the macro another error is given, Cannot yield reference to storage of type 'Set<Asset.ID>' (aka 'Set<PersistentIdentifier>') as an inout yield of type '<<error type>>'
.
To reproduce you can use this code block:
@MainActor @Observable
public final class NavigationStore {
// MARK: - Selection
var assetSelection: Set<Asset.ID> = []
}
@Model
public class Asset {
// MARK: - Properties
var name: String = ""
}
@available(macOS 26.0, *)
@Model
public class ImageAsset: Asset {
// MARK: - Properties
var imageName: String = "image"
}
@main
struct MyApp: App {
@State private var navigationStore: NavigationStore = NavigationStore()
var body: some Scene {
WindowGroup {
Text("Hello World!")
}
.modelContainer(
for: [
AssetGroup.self,
Asset.self,
ColorAsset.self,
ImageAsset.self,
SymbolAsset.self
],
isUndoEnabled: true
)
}
Thanks again for taking the time!