@Model issue in visionOS

It seems that @Model is not fully supported in visionOS. I've tried both an iPad app and a native visionOS app, and both crash when trying to use SwiftData. It's a minimal app from the template (no data) that I add a little data code to:

import SwiftData

@Model
final class mapPin {
  var lat : Double
  var lon : Double
  
  init(lat: Double, lon: Double) {
    self.lat = lat
    self.lon = lon
  }
}

Building for visionOS produces:

/var/folders/9p/ppkjrfhs393__cqm9z57k9mr0000gn/T/swift-generated-sources/@__swiftmacro_7Vision16mapPin5ModelfMm_.swift:2:13: error: declaration name '_$backingData' is not covered by macro 'Model'
private var _$backingData: any SwiftData.BackingData<mapPin> = SwiftData.DefaultBackingData(for: mapPin.self)
            ^
/Users/arenberg/Developer/Beta/Vision1/Vision1/ContentView.swift:13:7: note: in expansion of macro 'Model' here
final class mapPin {
      ^~~~~~~~~~~~~~
/var/folders/9p/ppkjrfhs393__cqm9z57k9mr0000gn/T/swift-generated-sources/@__swiftmacro_7Vision16mapPin5ModelfMc_.swift:1:1: error: type 'mapPin' does not conform to protocol 'PersistentModel'
extension mapPin : SwiftData.PersistentModel  {}
^
/Users/arenberg/Developer/Beta/Vision1/Vision1/ContentView.swift:13:7: note: in expansion of macro 'Model' here
final class mapPin {
      ^~~~~~~~~~~~~~
/var/folders/9p/ppkjrfhs393__cqm9z57k9mr0000gn/T/swift-generated-sources/@__swiftmacro_7Vision16mapPin5ModelfMc_.swift:1:1: note: do you want to add protocol stubs?
extension mapPin : SwiftData.PersistentModel  {}
^
/Users/arenberg/Developer/Beta/Vision1/Vision1/ContentView.swift:13:7: note: in expansion of macro 'Model' here
final class mapPin {
      ^~~~~~~~~~~~~~
/var/folders/9p/ppkjrfhs393__cqm9z57k9mr0000gn/T/swift-generated-sources/@__swiftmacro_7Vision16mapPin5ModelfMm_.swift:2:64: error: module 'SwiftData' has no member named 'DefaultBackingData'
private var _$backingData: any SwiftData.BackingData<mapPin> = SwiftData.DefaultBackingData(for: mapPin.self)
                                                               ^~~~~~~~~ ~~~~~~~~~~~~~~~~~~
/Users/arenberg/Developer/Beta/Vision1/Vision1/ContentView.swift:13:7: note: in expansion of macro 'Model' here
final class mapPin {
      ^~~~~~~~~~~~~~```

https://developer.apple.com/documentation/visionos-release-notes/visionos-release-notes

Unfortunately SwiftData's @Model macro in the Xcode toolchain isn't compatible with the visionOS SDK in beta1. More soon

Just been trying to get my SwiftData iOS app to run in visionOS but it just crashes, even tried to get a minimal visionOS app to work with SwiftData but just get errors. Hope its fixed soon

Per the documentation here, it's SwiftData isn't supported.

https://developer.apple.com/documentation/swiftdata

What would be alternative to use then? Core Data?

No, this is just a beta1 issue.

Will SwiftData be available for Vision OS?

Yeah, SwiftData should be available. Was glad to see this was a beta1 issue and not a misconfig on my end. Eager to get it integrated once it's working!

So is Beta 2 coming anytime soon?

Beta 2 is out and seems to have added support for SwiftData. 🤷‍♂️ at least it works fine for me.

@Model issue in visionOS
 
 
Q