Search code examples
iosswiftsprite-kitxcode6swift-playground

Cannot use SpriteKit in Xcode 6 Playground


I am trying to use SpriteKit in Xcode 6 playground like this:

import UIKit
import SpriteKit
import XCPlayground

var spriteView = SKView(frame: CGRectMake(0, 0, 1334, 650))
spriteView.backgroundColor = UIColor(red: 0.167, green: 0.165, blue: 0.164, alpha: 1.0) 
let rootScene = SKScene()

let rect = SKShapeNode(rect: CGRectMake(10, 10, 100, 100))

rect.fillColor = UIColor.redColor()

rootScene.addChild(rect)

spriteView.presentScene(rootScene)

XCPShowView("The Sprite View", spriteView)

But when I see Timeline I just see:

Xcode Playground

Can Anyone Help Me?


Solution

  • It seems like the iOS playgrounds doesn't play well at all with SpriteKit. I got mixed results running the playground in full simulator:

    Full Simulator screenshot

    And works reasonably under OSX using a previous created .sks in the "Resources" folder of the playground (just like the Balloons example)

    Found this comment too.