I am trying to play a system sound. Using Xcode 6 Beta 4. Here is the code:
func playKeyClick()
{
let filePath = NSBundle.mainBundle().pathForResource("Tock", ofType: "aiff")
if NSFileManager.defaultManager().fileExistsAtPath(filePath) {
println("file exists")
}
let fileURL = NSURL(fileURLWithPath: filePath)
var soundID:SystemSoundID = 0
AudioServicesCreateSystemSoundID(fileURL, &soundID)
AudioServicesPlaySystemSound(soundID)
}
It works fine on devices but does not play in the simulator. I have created a test app that does nothing but play this sound so I don't think I'm doing anything to stop it.
The simulator plays sound from the Safari app ok, so I assume that shows it is capable of playing sound from my app.
Note that I also have other code for playing sound in two other ways that also work on devices but not simulator. I chose this example for simplicity.
Edit - changed file to resource bundle to avoid confusion