56

Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app.

I can't find a sound setting anywhere in the simulator or Xcode preferences. I've tried resetting the simulator through "Reset Content and Settings" menu item to no avail.

9 Answers 9

79

On your Mac, go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects".

You need to re-activate your system sounds, see the end of this page.

6
  • 2
    Thanks -- this worked for me. Go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects". The iPhone Simulator suddenly started playing sound again after this.
    – Nick
    May 12, 2009 at 9:58
  • thanks it works for me too! :) with iPhone SDK 3.2 and OSX 10.6
    – Sadat
    Aug 21, 2010 at 6:02
  • When there are multiple sound output attached, please make sure the select the right output device in "Play sound effects through" drop option.
    – Leon
    Nov 30, 2012 at 3:59
  • 9
    Discussion on Apple.com has been deleted
    – Vincent
    Nov 6, 2014 at 11:32
  • 1
    The link is broken. So sad.
    – kelin
    Jan 7, 2017 at 12:33
23

I had no sound in the simulator, so I tested it with mobile safari and tried playing an mp3: No sound!

All the above tips didn't help. Eventually, I changed my INPUT source from the virtual soundflower device to Line-In, and the Simulator worked!

So, even if the app wasn't using input, it didn't work well with Soundflower.

3
  • worked for me too -- I'd switched input to a USB headset and needed to switch back to Line-In. +1.
    – jstevenco
    Oct 26, 2010 at 17:34
  • Wow.. banged my head for hours on this one on Xcode 4.2 with Lion 10.7.3! Definitely need to file a bug with apple on this! Thanks
    – jsherk
    Mar 30, 2012 at 0:31
  • WORKED This is soooo not intuitive. I would never have thought to check the INPUT. Now I can get the sound program tested (sigh). Jun 5, 2013 at 13:07
15

My symptoms were:

  • My app's sounds played in iPad simulator, but not in iPhone simulator
  • iPhone simulator sound was otherwise OK, e.g. YouTube in Safari

It appears there's a bug in Silent Mode for the iPhone simulator. To work around this, I turned Silent Mode on and then off again:

  1. In Simulator menu, turn on Window > Show Device Bezels.
  2. The bezel shows hardware buttons. Find the silent mode switch, and click it twice.
  3. Hide the bezels again, if preferred.

enter image description here

Thanks to Benzy Neez's answer for the hint that the issue related to AVAudioSession.Category.ambient.

1
  • 1
    Nice one! The workaround of cycling silent mode seems to last for the lifetime of the simulator session, but needs to be done again after re-starting the simulator.
    – Benzy Neez
    May 17, 2023 at 6:49
4

I've seen this problem after my update from OSX10.5.7 to 10.6.2

And I made the following changes to make the simulater sing again: Goto "Applications/Utilities" and run "Audio MIDI Setup", then change midi format from 48000 to 44100.

1
  • Thanks for the tip - my sound is still working in 10.6.2, but it's good to know that this fixed your issue.
    – pix0r
    Dec 8, 2009 at 18:04
3

OpenAL not working on the simulator was fixed with the 2.1 SDK. Make sure Active SDK and Active Executable are set to 2.1.

By the way, make sure you're using the last version of CrashLanding (v1.8). Some nasty leaks in SoundEngine were fixed recently.

3

I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).

A few things to remember:

  • call AudioSessionInitialize as soon as your app finishes launching
  • set the kAudioSessionProperty_AudioCategory property for the session via AudioSessionSetProperty (with a value such as kAudioSessionCategory_MediaPlayback)
  • call AudioSessionSetActive(YES)

Of course when all else fails, just run it on your hardware!

EDIT: Now that the 2.2 SDK has been released, I haven't had any problems with sound in the simulator. They must have fixed the bugs! I highly recommend you upgrade to the 2.2 SDK.

0
2

if reactivating system sounds didn't work for you try this: launch audio-midi-setup, then configure your "built in output" to use 44.100Hz, 2 channels, 24 bits. (from http://www.cocos2d-iphone.org/forum/topic/4159)

somehow after a few days, my iphone simulator now wants 48.000Hz, 2 channels, 24 bits. just play with it for a bit and be warned that it might change randomly when plugging in headphones, going to standby, restarting, etc.

and here's a an off-topic hint: when you plug headphones into your iphone/ipad the buffer size might double (e.g. from 512bytes to 1024 bytes), make sure you don't rely on the buffersize you requested!

1

Here are two other possible reasons why sound might not play on simulator devices:

  1. With Xcode 14.2 and simulators running iPadOS 16 / iOS 16, I noticed that sound was playing on iPad simulators, but not iPhone simulators. It turned out that this was related to the AVAudioSession.Category being set on the AVAudioSession. If the category is .ambient then sound plays on iPad but not iPhone simulators, if the category is .playback then it plays on both. Interestingly, this does not seems to be a issue for iOS 15, here .ambient category plays on iPhone simulators too.
  2. If you are calling AVAudioPlayer.play(atTime: TimeInterval) then the TimeInterval you pass in must be later than the device's current time. Passing 0 will not work and just plays nothing. Even passing a value > 0 may play nothing, you need to add the time offset to the deviceCurrentTime on the player. See the associated documentation for an example. This applies to real devices too of course, not just simulators.
1
  • Thank you! Reason 1 was the problem for me. Worked around by cycling Silent Mode, posted as a separate answer.
    – jedwidz
    May 17, 2023 at 6:29
0

I'm encountering this issue while running a watchOS simulator. In my case, the following worked:

  • Close the simulator in which the sound doesn't work.
  • Open another watchOS simulator.
  • Close it and reopen the original one.

Not the answer you're looking for? Browse other questions tagged or ask your own question.