ARSessionConfiguration在Xcode 9 GM中未解析

Lin*_*rth 6 ios arkit xcode9

ARKit使用测试版的Xcode 9 创建了一个项目,我可以在我的真实设备上运行而没有任何问题.
昨天,我升级到Xcode 9 GM,没有触及任何东西,Xcode显示多个错误,说它不知道ARSessionConfiguration即:

使用未声明类型'ARSessionConfiguration'

和:

使用未声明类型'ARWorldTrackingSessionConfiguration'

...对于此代码:

let session = ARSession()
var sessionConfig: ARSessionConfiguration = ARWorldTrackingSessionConfiguration()
Run Code Online (Sandbox Code Playgroud)

我已经导入ARKit并使用了ARSCNViewDelegate我的ViewController.
从Xcode的测试版打开项目时,它不会显示错误,我可以再次在手机上运行该应用程序.

知道如何解决这个问题吗?

Nan*_*tey 17

ARWorldTrackingSessionConfiguration已被弃用并重命名为ARWorldTrackingConfiguration:请参阅此处

此外,ARSessionConfiguration已被弃用并重命名为ARConfiguration,现在是一个抽象基类.

使用AROrientationTrackingConfiguration当你不想要的,而不是使用通用ARConfiguration世界跟踪.从而:

let configuration = AROrientationTrackingConfiguration()
Run Code Online (Sandbox Code Playgroud)

您还可以检查设备是否支持全球跟踪:

if ARWorldTrackingConfiguration.isSupported {
   configuration = ARWorldTrackingConfiguration()
}
else  {
   configuration = AROrientationTrackingConfiguration()
} 
Run Code Online (Sandbox Code Playgroud)


小智 6

在Xcode 9 GM中,看起来ARWorldTrackingSessionConfiguration已重命名为ARWorldTrackingConfiguration:

https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration

参考此更改:

https://github.com/markdaws/arkit-by-example/issues/7

ARSessionConfiguration已重命名为ARConfiguration:

https://developer.apple.com/documentation/arkit/arconfiguration