Post

Replies

Boosts

Views

Activity

visionOS and SwiftData: 'member' macro cannot be attached to property
Create a new Multiplatform App project Select SwiftData as a storage option In the main Target add Apple Vision as a Supported Destination target Select "Apple Vision Pro" as a run destination Build and run (start the active scheme) Expect: Successful build Actual: Build error: /var/folders/25/7fgb4nf92lx09_gptkqy42f80000gn/T/swift-generated-sources/@__swiftmacro_6Sherpa4Item5ModelfMm_.swift:2:13 'member' macro cannot be attached to property The code (with the macro expanded) looks like this: @Model final class Item { var timestamp: Date init(timestamp: Date) { self.timestamp = timestamp } @Transient private var _$backingData: any SwiftData.BackingData<Item> = SwiftData.DefaultBackingData(for: Item.self) // 'member' macro cannot be attached to property public var backingData: any SwiftData.BackingData<Item> { get { _$backingData } set { _$backingData = newValue } } static func schemaMetadata() -> [(String, AnyKeyPath, Any?, Any?)] { return [ ("timestamp", \Item.timestamp, nil, nil) ] } init(backingData: any SwiftData.BackingData<Item>) { self.backingData = backingData } @Transient private let _$observationRegistrar = Observation.ObservationRegistrar() // 'member' macro cannot be attached to property }
3
2
640
Aug ’23