I am using a 16" MacBook Pro (i9) and I'm running Xcode 12.2 on Big Sur (11.0.1).
Killing coreaudiod temporarily fixes the problem however this is not much of a solution.
Is anyone else having this problem?
Had the same issue when running Preview Canvas with Xcode 12.5.1.
Fixed it with going to System Preferences -> Sound -> Input -> Change it to Macbook Pro Microphone (Basically internal mic of your device).
Hope this helps you.
I have the same issue and know a fix for this and possibly the reason.
The fix is to go into the system preferences -> Sound, then go to input and change the input source to something other than your headphones. (shortcut: option + any volume key)
I don't know how to fix this at an Xcode level, or if you only have one input device though.
Just for anyone who cares, the reason for the stuffy audio is that Xcode starts a phone call, and I suppose my headphones don't like to output clean sound with the mic taking inputs. I know that Xcode is starting a call because my headphones have bluetooth multipoint, as well as giving me verbal feedback about whats going on with them. When bluetooth multipoint is active my audio will switch cleanly between my iMac and Ipad pro, unless one of them is taking a phone call then the phone call will get priority. When I get this muffled audio, my headphones won't switch to my Ipad to play audio, which suggests that a phone call is in progress. What really says that a call is in progress, is that when I change the input source in system preferences away from my headphones, the audio clears up but my headphones also say "call ended". All this means that Xcode must be starting a phone call for some reason, and my headphones don't like that.
Why my iMac speakers are happy to play music while "taking a phone call" but my headphones aren't may mean that it isn't a macOS issue but a limitation with the headphones, but this is just guess work.
As Ij000 mentioned, it's a Bluetooth limitation (turning on the mic channel leaves less bandwidth for music), but its worth noting it happens with AirPods too just to preempt any 'it must be your headphones' excuse.
Until then, you can get around it with any of the fake audio devices like Soundflower or Blackhole. Just remember to change it back before answering any calls on it!
Really does need fixing though. Like lots of others I listen to music & watch stuff while developing, so you can imagine how unbelievably frustrating it is to suddenly have to work in silence.
Don't want to come across negative but surely somebody at Apple has launched a simulator while wearing AirPods and noticed this, right? It's been doing this for (at least) two years?
I am having this issue almost all the time. Use case: Running XCode with a simulator and listening to Spotify. Always when you rerun the project or enable the "Debug view hierarchy" you hear annoying crackle and distortions in the music being played. I guess the reason can be also in my in-app muted videos, but it is still a bug from XCode. Now playing the music from the iPad :(
I have the same issue - the same MacBook Pro (2019) Intel i9 processor as the original post. I didn't notice it was caused by the simulator but it makes sense as I use the simulator for work all the time.
I am not interested in a workaround. I am not sure I understand why that's not fixed already
It's been more than 3 years (Intel + M1 machines) since I am experiencing this issue and it's very annoying that we don't have a proper solution for it. Every time the simulator gets launched audio crackling starts.
Current Setup: MacBook Pro Chip: Apple M1 Max RAM: 64 GB macOs: 13.2.1 Xcode 14.2
The XCode simulator generates sounds (anything from Picker wheel clicking to audio/haptic generated by the App) and every time it generates a sound it pauses any Bluetooth device I have connected for a second or two. When it starts again, the audio is distorted and audio level is changed. This is really annoying. From reading the replies above, I directed the system audio to the Mac Studio speakers and that solved the problem, but now I'm not getting the alerts as I'm on headphones. The solution is for Apple to overlay the two audio channels seamlessly without stopping/starting any audio.
This works like a charm, I was struggling for years with this glitch. And yes it has to be fixed :D
install Blackhole 2ch from: https://github.com/ExistentialAudio/BlackHole
With your Simulator open go to I/O > Audio output > Blackhole 2 ch.
This is not my answer, just reposted it for you to notice.