I have an ordinary .sks file in Xcode9, TestScene.sks.
Of course, you need an SKView to "hold" an .sks.
If I manually construct the SKView in code in the usual way it works fine. (I've included a handy example of that at the bottom of this post.)
However, in X9 you can simply add a SKView in storyboard.
And then just choose the .sks file in the Attributes inspect....
But.
It does not work. I just get this error:
Main.storyboard: Class Unavailable Xcode.IDEInterfaceBuilder.CocoaTouch.SKView
What could the problem be?
SpriteKit.framework is included in Link Binary ...
what could be the reason?
Point 1: for the record, how to manually add in code:
func manuallyAddSceneInCode() {
let sk: SKView = SKView()
sk.frame = view.bounds
sk.backgroundColor = .clear
view.addSubview(sk)
let scene = SKScene(fileNamed: "TestScene")!
scene.scaleMode = .aspectFit
scene.backgroundColor = .clear
sk.presentScene(scene)
}
Point 2 - as Knight asks below. If you "just drop a regular UIView and custom class it to SKView" - of course, you then don't get any of the "custom controls" for the class. (Just as if you say custom class a normal UIView to UILabel - it does not "work like" a UILabel in storyboard.)
Point 3 - Knight seems to have hit a nail on the head, indeed the class mentioned in the error is "Xcode.IDEInterfaceBuilder...." what the heck is that?
Point 4, I just tried in 9.0.1, same problem.
I just replicated your error. The problem seems to be related to the deployment target. If I deploy to iOS 9.0, I get your error, if I increase the deployment target to iOS 10, the error goes away. I guess storyboard only supports it that far.
EDIT:
I uploaded my demo project you can check:
https://github.com/seriouscyrus/SCSpriteKitStoryboard
In the Master branch, the deployment target is 9.0 and you get the error when you try to build, in the iOS10Deployment branch it is fixed. No need to restart anything.
Additionally my error gives more information, "SKView before iOS 10.0 (NSCoding was broken in previous versions".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With