19

With an iOS playground set up as simply as this:

import UIKit
import SpriteKit
import XCPlayground

let s = CGSize(width: 300, height: 300)
let f = CGRect(origin: CGPointZero, size: s)
let view = SKView(frame: f)
let scene = SKScene(size: s)
scene.backgroundColor = SKColor.redColor()
view.presentScene(scene)
XCPShowView("main view", view)

I'm getting this in the console:

2014-09-04 17:02:13.358 SpriteKitBETA7[2009:20695] Error sending deferral props: 0x10000003

There IS a "main view" box in the Assistant Editor thing, but it doesn't display anything. This exact same code (with import Cocoa instead of import UIKit) works perfectly on an OSX playground. I am aware I can just test stuff in an OSX playground (though it would be more convenient on an iOS one since I don't want to use Yosemite but I do have the iOS7 SDK) and copy-paste to my project, but I wanted to know if anyone understood what's happening here.

maltalef
  • 1,507
  • 2
  • 16
  • 27
  • Does the same problem persist if you comment XCPShowView()? In any case, you could try progressively commenting out stuff to see which line of code is the culprit. In general, I can't see anything obviously wrong with what you're doing (not a SpriteKit expert though) - so it might be worth filing a bug report with Apple about it – Enrico Granata Sep 13 '14 at 21:16
  • Effectively, the error is gone if I comment the XCPShowView call. Unfortunately, so is the debug display thing. Maybe now that I'm not even allowed to use OSX playgrounds (with the latest Xcode, the GM) it's time to file a bug report as you say. – maltalef Sep 16 '14 at 19:24
  • What version of OSX are you running? Some of the playground functionality is only available in Yosemite; for instance the sample project apple provided of the Playgrounds demo from the WWDC keynote was unable to run on mavericks. – cmyr Oct 21 '14 at 20:06

3 Answers3

19

Per the Xcode 6 Release Notes, you will want to enable Run in Full Simulator in the File Inspector. Keep in mind this will run kind of slow since it is running through iOS Simulator. You'll have to wait a while for the iOS Simulator to launch before your XCPShowView starts displaying in the playground's Timeline.

  1. In the Xcode menu bar, go to View > Utilities > Show File Inspector (++1)
  2. In the File Inspector on the right, under Playground Settings, make sure the Platform is set to iOS
  3. Make sure Run in Full Simulator is checked.

If you mouse over the Run in Full Simulator option it explains that you should use this with views that animate or use OpenGL. Both of which apply to using either SceneKit or SpriteKit.

Tallyn Turnbow
  • 236
  • 2
  • 4
  • This doesn't always work. When enabling the Run in full simulator option, either the scene flickers in the simulator. And, as an added "bonus" if you are testing out a playground scene with the size of an Ipad, the simulator stubbornly refuses to detect size and run in IPad mode. Even if you select from Hardware, iPad, then go back to code, change something and save, it will restart in Iphone mode. – lorddarq May 03 '15 at 09:45
  • @lorddarq You aren't supposed to be checking your results in the iOS Simulator app. That's why it's launched in the background. You should be checking your results in the Timeline view of the Playground. The simulator screen flickers because the buffer is being scaled and captured to be displayed in the timeline view. Also this is capturing the whole buffer, not just the screen. So the screen size of the iPad versus the iPhone does not matter. – Tallyn Turnbow May 04 '15 at 15:46
  • I understand but that seems to be a hack, rather than anything else. Can't Apple be Apple and just develop something properly ? – lorddarq May 05 '15 at 07:02
  • @lorddarq Seems pretty good to me for running live code on an iOS Simulator. I'm not sure why you think it's a hack, they clearly put a lot of work into getting it working with a live iOS Simulator environment. And it works really well! – Tallyn Turnbow May 06 '15 at 19:51
  • The reason why I think it's a hack is because if there's a timeline, I would want it to work without having to enable the simulator for that. Otherwise, why run it in timeline and not just the sim in the first place ? It's not convenient. Plus the sim consumes extra resources without giving back any significant benefits other than enabling the use of the timeline feature, which makes it suboptimal from my point of view. – lorddarq May 07 '15 at 21:01
  • @lorddarq It won't run in a full iOS Simulator without running a full iOS Simulator. I think it's pretty clear. – Tallyn Turnbow May 08 '15 at 22:28
  • On Xcode 7.1 (7B91b) it looks like "Run in Full Simulator" has been removed. Is there a workaround? – vopilif Nov 30 '15 at 23:12
0

What did you see? I got as far as seeing a scene view with a color background I want. Try this:

import UIKit
import SceneKit
import QuartzCore
import XCPlayground

let view = SCNView(frame: CGRectMake(0, 0, 300, 300))
let myScene = SCNScene()
view.scene = myScene
view.backgroundColor = UIColor.blueColor()
view.backgroundColor = UIColor.yellowColor()

let root = view.scene?.rootNode

XCPShowView("The Scene View", view)

You can test it by diff color, and it rendered it. However, if i add a sphere to the root node, nothing happens. And I also see this in my Console Output:

2014-09-13 16:59:35.766 SceneKitPlayground[23682:13804922] Error sending deferral props: 0x10000003

Additionally, if I switch the thing to OS X, the same code that add the sphere will work.

kawingkelvin
  • 3,649
  • 2
  • 30
  • 50
  • I just realized you are not using SceneKit, but SpriteKit. I haven't tried that. It could be worse if you don't even get as far as a view with a background color. – kawingkelvin Sep 13 '14 at 21:06
  • So, the same thing happens with SceneKit. OK, interesting. BTW, I think the reason you can change the background color is you're doing it to the view, not the scene, like me. I can do `view.backgroundColor = SKColor.greenColor()` in my code and it shows too. – maltalef Sep 16 '14 at 19:26
  • I just saw this error happening in a playground again, and this time, i was only doing plain UIView stuff. Forgot what I have done... will post if I find it. – kawingkelvin Sep 18 '14 at 16:10
  • Yes, I got this message in the "Console Output" only doing "plain" UIView stuff, will post the details as a separate "Answer". – kawingkelvin Sep 21 '14 at 18:26
  • Actually, the culprit is XCPShowView(). So this error may not be helpful in debugging the SpriteKit or SceneKit render issue. – kawingkelvin Sep 21 '14 at 18:34
  • Unfortunately I'm seeing the same thing ... has anyone here been successful at getting this to work? – Joel Martinez Oct 23 '14 at 02:38
0

I managed to get it running by opening the file inspector, changing the playground settings to OSX, then back to iOS and checking 'Run in Full Simulator'. This is in XCode 6.1.

dylanrw
  • 1
  • 3