user2255273
user2255273

Reputation: 958

Play sound in Sprite Kit

I have the following code in myScene.h :

#import <AVFoundation/AVFoundation.h>

And this code in the touchBegin method:

[self runAction:[SKAction playSoundFileNamed:@"fire.m4a" waitForCompletion:NO]];

The audio file is in the main folder. When I run the app and touch the app is shut down and I get the following error:

Terminating app due to uncaught exception 'Missing Resource', reason: 'Resource fire.m4a cannont be found in the main bundle'

I thought this is the way to play audio in Sprite Kit but I must be doing something wrong..

Upvotes: 7

Views: 5962

Answers (1)

Greg
Greg

Reputation: 25459

Delete the file from your project and add it again. Remember to select

Copy items into destination group...

And select your project as a target (not test).

Upvotes: 11

Related Questions