Swift iOS playground: Error sending deferral props

本秂侑毒 提交于 2019-11-29 11:13:42

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/25674183/swift-ios-playground-error-sending-deferral-props

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!