RealityKit uses unprefixed types, like SwiftUI, but unlike traditional frameworks such as SpriteKit or Core Graphics.
Both SwiftUI and RealityKit have a Scene type. In SwiftUI, Scene is used in the app entry point:
import SwiftUI
@main
struct MyApp: App {
/// Scene type
var body: some Scene {
WindowGroup {
HomeView()
}
}
}
In RealityKit, Scene is where content lives. The type is used in many places, for example to create a system:
import RealityKit
class MySystem: System {
/// Init with a reference to the scene
required init(scene: Scene) {
}
}
If the file imports both RealityKit and SwiftUI, then one of the Scene types will require disambiguation. Use the module name as a prefix:
import SwiftUI
import RealityKit
class MySystem: System {
/// Disambiguate the Scene type
required init(scene: RealityKit.Scene) {
}
}
I find it remarkable that the same generic Scene term is used in both frameworks without prefixes. Traditional Apple frameworks prefix their types, for example SKScene for a SpriteKit scene, or UIView for a UIKit view. While all RealityKit types are unprefixed: Scene, Entity, Component, System, etc., similarly to SwiftUI: Path, Shape, Color, etc.
Are these prefix-free types meant to converge? Are they the last expected occurrence of their kind in Apple land?