Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

SpaceCat Spritekit Game fatal error

i followed the tutorial of the space cat spritekit shooter. all went fine until i today followed the steps that implemented the spacedognodes.

wenn the video said "now let's start the game in the simulator" i get an error after the transition from the titlescene to the gameplay scene, the app crashes: "libc++abi.dylib: terminating with uncaught exception of type NSException".

it highlights a line in main.m (which i haven't touched since the very beginning of the tutorial): return UIApplicationMain(argc, argv, nil, NSStringFromClass([THAppDelegate class])); It also shows "Thread 1: signal SIGABRT".

i am completely lost here. the app crashes as soon as i touch the titlescreen and where it is supposed to transition to the gameplayscene - which always worked fine until today.

when i run the app in the simulator or ios device it says "build succeeded". it shows no errors yet the app crashes as soon as i transition to the gameplay scene.

very strange and too much for my little knowledge to understand what is happening here.

2 Answers

thank you, stone preston, for your encouraging words to scan again calmly for the error.

the console told me that i attempted to add a SKNode which already had a parent: <SKSpriteNode> name:'(null)' texture:[<SKTexture> 'spacedog_A_1@2x.png' (43 x 128)] position:{100, 300} size:{64, 64} rotation:0.00'

i still didn't know what could possibly have went wrong. and where. i thought i lost the flow and everything. but, by rewatching the lesson and carefully checking my code line per line i came across the culprit:

it turned out that i accidentally forgot to alter a copied-and-pasted content in the addSpaceDog method. instead of spaceDogA and spaceDogB i "accidentally" added 2 times spaceDogA and this caused the app to crash.

it is working fine now.

Stone Preston
Stone Preston
42,016 Points

awesome. nice job figuring it out on your own : )

Stone Preston
Stone Preston
42,016 Points

youve got an uncaught exception being thrown. there should be more information about the exception in the console. after it crashes, look around some more in the console to see if you can find the info. it will tell you specifically whats causing the exception to be throw.