Updated to Xcode 10.1 on Mojave and now my app alw

2019-02-11 21:47发布

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

1条回答
做自己的国王
2楼-- · 2019-02-11 22:28

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.

查看更多
登录 后发表回答