I just figured this out today! For those that are potentially having a similar problem,
Have a class similar to -
@MainActor
class MyClass: ObservableObject, @unchecked Sendable { ... }
Make sure this class has all instances of DataProviders you need and also has an instance of ARKitSession.
Then, in your main file or wherever you declare your App's SwiftUI.Scene, have something similar to this outside of the App block:
@MainActor
enum MyClassContainer {
private(set) static var myClass = MyClass()
}
and inside of your SwiftUI.Scene block -
ImmersiveSpace(id: "myId") {
MyImmersionView(myClass: MyClassContainer.myClass)
}
.immersionStyle(selection: $immersiveController.currentStyle, in: .mixed)
then, make sure you actually run the ARKitSession inside of your immersive space inside of a .task{} method chain off the end of the RealityView block!
Hope this helps :)
Topic:
Spatial Computing
SubTopic:
ARKit
Tags: