I am running a AVAudioSession which I suspect is activating the microphone request, but I only use it for sounds and music. When running Xcode 10.1 Simulator on macOS Mojave, why does it activate a request to access the microphone? I haven't written a single line to even ask access to it. My app doesn't need access to it nor do I want it to. Here's the code to play the music:
AVAudioSession *title = [AVAudioSession sharedInstance];
[title setCategory:AVAudioSessionCategoryAmbient error:nil];
[title setActive:YES error:nil];
//MUSIC
NSString *path = [[NSBundle mainBundle] pathForResource:@"music_nature" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:path];
titleMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
titleMusic.numberOfLoops = -1;
[titleMusic setVolume:1.0];
[titleMusic play];
If I comment out the above code, I will no longer get a request for the microphone. But then I don't have any music.
Sample project: https://github.com/Coeur/StackOverflow53109911
(you need macOS Mojave to reproduce the issue)
I also got this problem recently on an audiostreaming app that has been working ok for years without the microphone access popup. It happens when you try to get the AVAudioSession.
Update: Seems like Xcode 10.2 (beta 1) solves this by only asking the first time and then remembering your answer.
Update2: Xcode 10.2 is now out and only asks the first time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With