Mikael
Mikael

Reputation: 3612

Error: Use of undeclared type 'SCNView'

Im doing a transition from Obj-C to Swift and after 5 seconds I'm stuck :/

  1. I have a storyboard with a SCNView object
  2. I drag a connection to my view controller
  3. Xcode writes out @IBOutlet var scene: SCNView!

I get the error:

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

Use of undeclared type 'SCNView'

What is this?

I'm using latest Xcode 6.3.

Upvotes: 3

Views: 1884

Answers (1)

rickster
rickster

Reputation: 126107

You need to tell Swift about the frameworks (modules) you intend to use in a source code file with the import statement, just like you tell ObjC about such using #importor #include.

import SceneKit 

class MyViewController: UIViewController {
    @IBOutlet var sceneView: SCNView!
    // ...
}

This both makes the classes, functions and other symbols available for use in your source file and makes Xcode link in the SceneKit framework binary when building your app.

Upvotes: 6

Related Questions