Search code examples
swiftxcodescenekitcollada

xcode9 / SceneKit - .dae file not loading into SCNScene - returns nil


I'm trying to load a .dae file into SCNScene, using the following code:

let solutionScene = SCNScene(named: "art.scnassets/level1.dae")
print(solutionScene?.rootNode) // prints nil

solutionNode = solutionScene?.rootNode.childNode(withName: "level1", recursively: true)

I exported the .dae file from Blender as COLLADA with default settings, contains just a one simple object.

When i click on the .dae file in my art.scnassets folder in XCode, it opens without problem and i can see the geometry, camera etc.

I just can't get it loaded in the SCNScene. Is there anything i missed either on Blender side or Xcode/Swift side?


Solution

  • In case somebody runs into a similar newbie problem, the issue gets resolved by adding the .scnassets folder into "Copy Bundle Resources" under Build Phases of the project - cleaning the project might be required in some cases before you rebuild again. This solved my issue.