【问题标题】:ARSessionConfiguration unresolved in Xcode 9 GMXcode 9 GM 中未解决的 ARSessionConfiguration
【发布时间】:2018-03-01 09:43:38
【问题描述】:

我使用 Xcode 9 的 beta 版本创建了一个 ARKit 项目,我能够在我的真实设备上毫无问题地运行该项目。
昨天升级到Xcode 9 GM,什么都没碰,Xcode显示多个错误,说不知道ARSessionConfiguration即:

使用未声明的类型“ARSessionConfiguration”

和:

使用未声明的类型“ARWorldTrackingSessionConfiguration”

...对于此代码:

let session = ARSession()
var sessionConfig: ARSessionConfiguration = ARWorldTrackingSessionConfiguration()

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

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

【问题讨论】:

    标签: ios arkit xcode9


    【解决方案1】:

    ARWorldTrackingSessionConfiguration 已被弃用并重命名为ARWorldTrackingConfigurationSee here

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

    当您不想要世界跟踪时,请使用AROrientationTrackingConfiguration,而不是使用通用 ARConfiguration。因此:

    let configuration = AROrientationTrackingConfiguration()
    

    您还可以检查设备是否支持世界追踪:

    if ARWorldTrackingConfiguration.isSupported {
       configuration = ARWorldTrackingConfiguration()
    }
    else  {
       configuration = AROrientationTrackingConfiguration()
    } 
    

    【讨论】:

      【解决方案2】:

      在 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

      【讨论】:

      • 关闭,但不完全——ARConfiguration 现在是一个抽象基类。如果您在测试版中直接使用 ARSessionConfiguration(仅用于 3DOF 跟踪),那么您现在需要的是 AROrientationTrackingConfiguration
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-20
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多