NSInvalidArgumentException in SpriteKit Swift

300 views Asked by At

I have an app with a SpriteKit scene. But if I run it on iOS 10.0 I'll get some error:

2018-11-09 21:58:26.379 App[56426:2425030] -[SKEmitterNode scaleMode]: unrecognized selector sent to instance 0x7c27adf0
2018-11-09 21:58:26.387 App[56426:2425030] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SKEmitterNode scaleMode]: unrecognized selector sent to instance 0x7c27adf0'

View's hierarchy

If I change View's class to UIView nothing will change.

Here is my scene setup:

if let scene = SKScene(fileNamed: "TandM") {
            scene.size = self.view.frame.size
            scene.scaleMode = .resizeFill
            tandmScene.presentScene(scene)
        }

But it's not trigger.

Full log.

1

There are 1 answers

0
Alexander Ruzmanov On

"Do not create SKViews in Interface Builder in your storyboard, even if they are embedded in a UIView." https://developer.apple.com/library/archive/qa/qa1889/_index.html

Try to insert your SKView into view hierarchy in viewDidLoad method instead of adding it in storyboard. It should help.

I suggest, that this bug is fixed for iOS 11 and later, but it's unfortunately actual for iOS 10.