Problem with SKAction.playSoundFileNamed:

Is there something that I am missing when using SKAction.playSoundFileNamed: I can get sounds to playback perfectly on the simulator but when I try on the device I get nothing at all. I am assuming this is a bug, I have tried this on the last few betas with no luck, it seems strange that its still around now we are at beta 5.


// Nothing magical, just using ...
self.sprite.runAction(SKAction.playSoundFileNamed("Ready_001.wav", waitForCompletion: false))

Hi, can anyone verify that this is a problem, then I can look further if it should be working.


    override func didMoveToView(view: SKView) {
        self.runAction(SKAction.playSoundFileNamed("Woohoo.wav", waitForCompletion: false))
    }


As mentioned, works on Simulator, fails on Device ... You will need to supply your own wav file 🙂


I am using:

OS X El Capitan Version 10.11 Beta (15A244d)

Xcode Version 7.0 beta 5 (7A176x)

iOS Version 9 beta 5

Does anyone have any ideas or work arounds for SKAction.playSoundFileNamed no working on devices? I have again tried this on 9.1 (Using an iPhone 6) with no luck. Running the same code on the simulator works fine.

I can't get it to run on Simulator or device on my side 😟

Did you check your sound filename has the correct upper/lower case? Simulator doesn't care about case in filenames, but the device does.

did you ever solve your problem?


I have a similar problem, but only on one computer.


instead of playing the sound, the app crashes, and I get a strange error message in the cosole:


error: use of undeclared identifier '$r0'


i wish I knew how to clean it all up so this error doesn't happen. I already reinstalled xcode and reinstalled mac os...

I also encountered this problem. Have no idea how to solve it.


EI Capitan + Xcode 7.0 + iphone 6s plus

Was this ever resolved? I am having the same problem with Xcode 10.1.


let swooshSound = SKAction.playSoundFileNamed("swoosh.caf", waitForCompletion: false)
run(swooshSound)

Okay, so I just solved my issue, not sure if anyone else was having the same problem. I thought the speakers were working just fine on my iPad because it was playing music and videos with sound just fine, but it turns out that "Silent Mode" was on, which muted the app I was testing. Not sure if that is related to the issues that others were having.

On IOS14, you must init the playback interface. SpriteKit use AVFundation to play sound with SKAudioNode.

In the appDelegate, do :

Code Block
#import "AppDelegate.h"
@import AVFAudio;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
    [audioSession setActive:YES error:nil];
    return YES;
}


You could also include the AVAudio.framework in the list of your frameworks.

Problem with SKAction.playSoundFileNamed:
 
 
Q