我是iOS开发的新手。我正在尝试运行Xcode 6中包含的示例SpriteKit。它在目标8.0中的模拟器上运行,并且目标设置为7.1。
当我尝试在我的设备(iPhone 5,iOS 7.1.1)上运行它时,在渲染精灵时它似乎与EXC_BAD_ACCESS一起崩溃(请参阅下面的堆栈跟踪)。我没有以任何方式更改Xcode 6中提供的示例中的代码。我尝试过其他开源的SpriteKit项目并遇到相同类型的错误。
如果我注释掉代码以便仅在用户触摸时调用self.addChild(sprite)
,则在触摸屏幕之前它会正常运行。
我认为这可能是Xcode6的一个错误,但谷歌搜索我发现没有其他人有类似的问题。我是否设置了我的开发环境或以某种方式错误地构建了项目? (注意:xcassets似乎没问题)
代码更改的堆栈跟踪:
* thread #1: tid = 0x6dad7, 0x322ac8ee SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) const + 238, queue = 'com.apple.spritekit.renderQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x322ac8ee SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) const + 238
frame #1: 0x322ad366 SpriteKit`SKCRenderer::preprocessSpriteImp(std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&, float, unsigned int&, bool) const + 2918
frame #2: 0x322a81d8 SpriteKit`SKCRenderer::preprocessAndSubmitSpriteInternal(std::__1::vector<SKCRenderer::SpriteRenderInfo const*, std::__1::allocator<SKCRenderer::SpriteRenderInfo const*> >&, std::__1::vector<SKCRenderer::SpriteRenderInfo, std::__1::allocator<SKCRenderer::SpriteRenderInfo> >&, SKRenderQuadPool&, SKCSprite const*, _GLKMatrix4 const&) + 52
frame #3: 0x322a6ca8 SpriteKit`SKCRenderer::preprocessAndSubmitSprite(SKCSprite const*, _GLKMatrix4 const&) + 152
frame #4: 0x322aae72 SpriteKit`SKCRenderer::submitScene(SKScene*) + 374
frame #5: 0x322ad91c SpriteKit`SKCRenderer::renderScene(SKScene*) + 148
frame #6: 0x32270eac SpriteKit`-[SKView _renderContent] + 1076
frame #7: 0x3a7ccd3e libdispatch.dylib`_dispatch_client_callout + 22
frame #8: 0x3a7d16c2 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 26
frame #9: 0x32270a4a SpriteKit`-[SKView renderContent] + 82
frame #10: 0x322720a6 SpriteKit`-[SKView layoutSubviews] + 478
frame #11: 0x3237c304 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 380
frame #12: 0x31ff831a QuartzCore`-[CALayer layoutSublayers] + 142
frame #13: 0x31ff3b3e QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 350
frame #14: 0x32022b4c QuartzCore`-[CALayer layoutIfNeeded] + 140
frame #15: 0x323f889e UIKit`-[UIViewController window:setupWithInterfaceOrientation:] + 242
frame #16: 0x323f6ea8 UIKit`-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3512
frame #17: 0x323f60e6 UIKit`-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 46
frame #18: 0x323f606e UIKit`-[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 94
frame #19: 0x323f6006 UIKit`-[UIWindow _setRotatableViewOrientation:duration:force:] + 42
frame #20: 0x323ee680 UIKit`__57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 108
frame #21: 0x32382696 UIKit`-[UIWindow _updateToInterfaceOrientation:duration:force:] + 382
frame #22: 0x323f5d58 UIKit`-[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 696
frame #23: 0x323f5828 UIKit`-[UIViewController _tryBecomeRootViewControllerInWindow:] + 160
frame #24: 0x32387614 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 460
frame #25: 0x32384dd8 UIKit`-[UIWindow _setHidden:forced:] + 304
frame #26: 0x323eea50 UIKit`-[UIWindow makeKeyAndVisible] + 60
frame #27: 0x323eb6e4 UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1820
frame #28: 0x323e5cc8 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 720
frame #29: 0x32381c96 UIKit`-[UIApplication handleEvent:withNewEvent:] + 3550
frame #30: 0x32380df8 UIKit`-[UIApplication sendEvent:] + 72
frame #31: 0x323e5404 UIKit`_UIApplicationHandleEvent + 616
frame #32: 0x349eeb54 GraphicsServices`_PurpleEventCallback + 608
frame #33: 0x349ee73e GraphicsServices`PurpleEventCallback + 34
frame #34: 0x2fb17846 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #35: 0x2fb177e2 CoreFoundation`__CFRunLoopDoSource1 + 346
frame #36: 0x2fb15fae CoreFoundation`__CFRunLoopRun + 1406
frame #37: 0x2fa80768 CoreFoundation`CFRunLoopRunSpecific + 524
frame #38: 0x2fa8054a CoreFoundation`CFRunLoopRunInMode + 106
frame #39: 0x323e462a UIKit`-[UIApplication _run] + 762
frame #40: 0x323df890 UIKit`UIApplicationMain + 1136
* frame #41: 0x0002ae50 TestGame`top_level_code + 88 at AppDelegate.swift:12
frame #42: 0x0002ae8c TestGame`main + 48 at AppDelegate.swift:0
以编程方式调用addChild(sprite)时的堆栈跟踪:
* thread #1: tid = 0x6e80d, 0x32296580 SpriteKit`SKCSprite::update(double) + 472, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xb)
frame #0: 0x32296580 SpriteKit`SKCSprite::update(double) + 472
frame #1: 0x3225de36 SpriteKit`-[SKScene _update:] + 174
frame #2: 0x3227335c SpriteKit`-[SKView(Private) _update:] + 324
frame #3: 0x322709b4 SpriteKit`-[SKView renderCallback:] + 820
frame #4: 0x3226e3ea SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 130
frame #5: 0x32290ede SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 254
frame #6: 0x0025b5ee libglInterpose.dylib`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 270
frame #7: 0x32046eee QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 98
frame #8: 0x32046c98 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
frame #9: 0x34e1675c IOMobileFramebuffer`IOMobileFramebufferVsyncNotifyFunc + 104
frame #10: 0x308375c8 IOKit`IODispatchCalloutFromCFMessage + 248
frame #11: 0x2fb0cc54 CoreFoundation`__CFMachPortPerform + 136
frame #12: 0x2fb17846 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #13: 0x2fb177e2 CoreFoundation`__CFRunLoopDoSource1 + 346
frame #14: 0x2fb15fae CoreFoundation`__CFRunLoopRun + 1406
frame #15: 0x2fa80768 CoreFoundation`CFRunLoopRunSpecific + 524
frame #16: 0x2fa8054a CoreFoundation`CFRunLoopRunInMode + 106
frame #17: 0x349ed6d2 GraphicsServices`GSEventRunModal + 138
frame #18: 0x323df890 UIKit`UIApplicationMain + 1136
* frame #19: 0x000a1e50 TestGame`top_level_code + 88 at AppDelegate.swift:12
frame #20: 0x000a1e8c TestGame`main + 48 at AppDelegate.swift:0