I have made a .reality file in Reality Composer and have imported it into Swift Playgrounds however I cannot find a way on how to run the file.
How would I go about this?
I have made a .reality file in Reality Composer and have imported it into Swift Playgrounds however I cannot find a way on how to run the file.
How would I go about this?
Reality Files can be opened with the RealityKit framework: you can load them by calling try Entity.load(named: "MyFile")
or another variation of this function.
It still does not work, I get errors with the code below: `import RealityKit
struct Content: View { var body: some View { Entity.load(named: "RealityView") } }`
The load(named:in:) function returns an Entity
, and Entity
does not conform to View
, so it is not valid as the return value of a ViewBuilder
, and results in a compile-time error.
Typically, you add entities into an ARView's Scene
, which RealityKit renders. Note however that ARView
is a UIView/NSView, and also does not conform to SwiftUI.View
. To use ARView
in SwiftUI, you can wrap it in a representable container. As a starting point, I recommend that you create a new project in Xcode that uses the "Augmented Reality App" template, and that you specify SwiftUI as the Interface, and RealityKit as the Content Technology.