Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updated to Xcode 10.1 on Mojave and now my app always asks to use the microphone

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)

Screen shot demonstrating error message

like image 277
MrCoinOp Avatar asked Nov 01 '18 21:11

MrCoinOp


1 Answers

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.

like image 84
jalmaas Avatar answered Nov 08 '22 18:11

jalmaas