在使用Xcode模拟器构建时禁用RealityKit/ARKit

3

在构建Xcode模拟器时,是否可以禁用RealityKit/ARKit/AR?以便我可以更改非AR相关页面的样式/内容。

我想要更改我的主页,添加不同的部分并进行样式设计。主页与ARKit/Reality Kit无关,但我没有带着物理设备。

错误提示称,各种RealityKit/ARKit函数未定义或不存在。例如ARView没有成员.occlusion。

主页根本不需要AR,是否可以构建和运行模拟器,甚至在没有(启用AR)物理设备的情况下预览?


2
顺便说一下,普通的ARKit是可以的。只有RealityKit在模拟器上无法工作。 - aheze
1个回答

1
你可以使用条件编译块,如Swift编程手册中所述:
class SubclassedARView : ARView {

    var configuration: ARWorldTrackingConfiguration()
    var runOptions: ARSession.RunOptions()

    init() {

#if !targetEnvironment(simulator)

        // Code here is only compiled when building to a real or generic device. 

        // This is the place where you should add your RealityKit specific
        // code, or at least the code that gives build-time errors in Xcode. 

        // An example of a problematic method:
        session.run(configuration, options: runOptions)

#endif

    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接