I am new to iOS development. I'm trying to run the sample SpriteKit included in Xcode 6. It runs on the emulators both in target 8.0, and with the target is set to 7.1.
When I try and run it on my device (iPhone 5, iOS 7.1.1), it appears to crash with EXC_BAD_ACCESS upon rendering sprites (see stack trace below). I have not changed the code from the sample provided in Xcode 6 in any way. I have tried other open source SpriteKit projects and encounter the same type of error.
If I comment out code so as to call self.addChild(sprite)
only upon user touch, it runs fine until the screen is touched.
I thought this might be a bug with Xcode6, but googling I find no one else with a similar issue. Have I set up my development environment or built the project wrong somehow? (Note: xcassets appears to be fine)
Stack trace with code unchanged:
* 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
Stack trace when addChild(sprite) is called programmatically:
* 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