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 to get the AVAudioSession
Update: Seems like Xcode 10.2 (beta 1) solves this by only asking the first time and then remembering you answer.