Turn off sound in iPhone Simulator
IosObjective CXcodeMacosIos SimulatorIos Problem Overview
Is there an option to turn off the sound on the iPhone Simulator? Or to adjust the volume?
Ios Solutions
Solution 1 - Ios
Partial Success - There are no good options
The iPhone Simulator selects the currently selected output at launch. Using Soundflower plugin and sending the audio to nowhere I started the iPhone Simulator. If you then switch to a different, working, output the simulator will remain 'muted' until you restart the simulator. So in general, you can attempt to trick the simulator to output to a dead end output.
Experimental setup - A sample video player
I'm working on a solution to this problem and as a first step created a demonstration video player app. You can download VideoPlayer from GitHub for your own experiments.
First Attempt - Use a 3rd party app to mute it
Tried using Audio Hijack Pro by Rogue Amoeba to hijack the audio stream and mute it. This didn't work and crashes the simulator. Contacted support and they reported that iPhone Simulator does some things that prevent them from hijacking the audio. I also looked into Soundflower and Jack.
Second Attempt - In-app mute
I was thinking maybe you could make a debug option where when in the app and on the simulator sound would be muted. However, within an app, only private APIs have the power to mute or reduce volume for the device. In the book iPhone Open Application Development Chapter 6, Example "What's My Volume' gives sample code for manipulating system-wide sound through the AVSystemController. It might be fun to explore this route, but to make it into a weaponized tool would require a lot of trouble since you need to compile against private headers.
Idea Three
Find a command-line option to pass to the Springboard or iPhone Simulator that will mute sound, or re-enable the volume control within the simulator, and of course be able to still launch the debugger.
Enhancement Request
I filed an Apple Bug Report enhancement request for both iPhone Simulator volume control, request 13428429, and per application volume control in Mac OS X, request 13428420. If you want these features, please file your own bug.
Solution 2 - Ios
I ran into this -- my (working) music audio was being routed through the iOS simulator before reaching my headphones, making the music tinny and low-quality. This made developing in the sim really annoying. Fortunately there's an easy fix:
- In the simulator, route the incoming sound from your Mac's microphone
- Still in the simulator, route the outgoing audio through your Mac's speakers, or any other audio channel you aren't using
Changing the incoming audio route:
Changing the outgoing audio route:
Solution 3 - Ios
Solution 4 - Ios
Open iOS Simulator, press Hardware > Decrease Volume (⌘↓) until it's muted! I think it was added at Xcode 9.2, and that it's available only when running sim with iOS 11 and above
Solution 5 - Ios
-
Download the Loopback app
-
In Loopback, create a new virtual audio device (click
New virtual device
). Rename it if you want (I named itBlackhole
). -
In Simulator, click
Hardware > Audio output
and choose the name of the virtual audio device that you just created.
Solution 6 - Ios
You can use something like...
#if DEBUG
[ myAudioController setVolume: .1 ];
#endif
This way during testing, the app will have a lower volume.
Solution 7 - Ios
referred from : https://stackoverflow.com/questions/4772112/ios-simulator-sound
>Both the input and output device much match in system sound settings. Often u have them set to different devices. If they don't match, the simulator seems to default to the last connected audio device selected among the input and output devices.
I hope it helps out in any way.
Solution 8 - Ios
In my case i just set audio output to somewhere which is muted. Like my external screen :)
Solution 9 - Ios
Solution for tvOS simulator:
Go to menu -> General -> Video and Audio -> turn 'Navigation Clicks' and 'Sound Effects and Music' off
Solution 10 - Ios
[[MPMusicPlayerController applicationMusicPlayer] setVolume:0.0];
This works for device, just give a try for simulator. https://stackoverflow.com/questions/215524/how-do-you-set-the-hardware-volume-in-an-iphone-app
You can even try the reverse of this thread to see. https://stackoverflow.com/questions/302399/sound-not-working-in-iphone-simulator
Solution 11 - Ios
Simple solution.
-
Make sure you have 2 outputs in your mac. For example, built in speakers and headphones.
-
Close the iOS Simulator.
-
Change the output source to the one you are not using (alt-click over the speaker in the top bar).
-
Run again the iOS simulator. It will take its default output source
to the one in the system. -
Change the output source to the one you are using and enjoy. The iOS simulator doesn't update it's output source when the system changes it.