在Mojave上更新为Xcode 10.1,现在我的应用程序总是要求使用麦克风 [英] Updated to Xcode 10.1 on Mojave and now my app always asks to use the microphone

查看:103
本文介绍了在Mojave上更新为Xcode 10.1,现在我的应用程序总是要求使用麦克风的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个AVAudioSession,我怀疑它正在激活麦克风请求,但是我仅将其用于声音和音乐.在macOS Mojave 上运行Xcode 10.1 Simulator时,为什么会激活访问麦克风的请求?我还没有写过一行来要求访问它.我的应用程序不需要访问它,也不需要它.这是播放音乐的代码:

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.

示例项目: https://github.com/Coeur/StackOverflow53109911
(您需要macOS Mojave 重现该问题)

Sample project: https://github.com/Coeur/StackOverflow53109911
(you need macOS Mojave to reproduce the issue)

推荐答案

我最近在一个音频流应用程序上也遇到了这个问题,该应用程序运行了好几年没有出现麦克风访问弹出窗口.尝试获取AVAudioSession时会发生这种情况.

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.

更新:好像Xcode 10.2(测试版1)可以解决此问题,方法是只问一遍,然后记住答案.

Update2:Xcode 10.2现在已经发布,只在第一次询问.

Update2: Xcode 10.2 is now out and only asks the first time.

这篇关于在Mojave上更新为Xcode 10.1,现在我的应用程序总是要求使用麦克风的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆