I suspect this has something to do with the new XCode update.
After updating to XCode 13, my app now gives me the error of Fatal errorUnexpectedly found nil while unwrapping an Optional value
The error comes from the first line:
let scene = SCNScene(named: "art.scnassets/Pokeball.scn")!
let ship = scene.rootNode.childNode(withName: "pokeball", recursively: false)!
ship.position = SCNVector3(0, 0, -0.3)
sceneView.scene = scene!
I did not modify the code so I have no idea why it is no longer functional. I double checked the file path and names are correct, I swapped to the default ship model file and still fails. What do I need to change to fix this?
You are force-unwrapping 3 Optionals, and you say the error comes from the first line.
• SCNScene(named: "art.scnassets/Pokeball.scn")!
• scene.rootNode.childNode(withName: "pokeball", recursively: false)!
• scene!
"scene!" doesn't make sense, since "scene" is not an Optional... I would expect this to give you a compiler error.
I suggest you try some simple diagnostics, like:
if let scene = SCNScene(named: "art.scnassets/Pokeball.scn") {
print("got scene: art.scnassets/Pokeball.scn")
} else {
print("couldn't find scene: art.scnassets/Pokeball.scn")
}