错误:使用未声明的类型'SCNView'

Mik*_*ael 2 storyboard ios scenekit swift

我正在从Obj-C过渡到Swift,5秒钟后我被卡住了:/

  1. 我有一个带有SCNView对象的情节提要
  2. 我将连接拖动到我的视图控制器
  3. Xcode写出 @IBOutlet var scene: SCNView!

我得到错误:

'weak' cannot be applied to non-class type '<<error type>>'

Use of undeclared type 'SCNView'
Run Code Online (Sandbox Code Playgroud)

这是什么?

我正在使用最新的Xcode 6.3。

ric*_*ter 5

您需要使用import语句将要在源代码文件中使用的框架(模块)告诉Swift ,就像您使用#import或告诉ObjC这样的框架一样#include

import SceneKit 

class MyViewController: UIViewController {
    @IBOutlet var sceneView: SCNView!
    // ...
}
Run Code Online (Sandbox Code Playgroud)

这不仅使类,函数和其他符号可在源文件中使用,而且在构建应用程序时使SceneKit框架中的Xcode链接变为二进制。