- 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
}
Found this in the release notes for beta 6 under known issues: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes
@Model classes with initial values for stored properties result in an error that self._$backingData is used before being initialized. (113572344)
and
visionOS projects that use the @Observable property wrapper will fail to build in Xcode 15 beta 3. (111494849)
Seems related...