xcode 需要 NSBluetoothAlwaysUsageDescription,但不使用蓝牙
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/57987863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NSBluetoothAlwaysUsageDescription required, but bluetooth is not used
提问by Nik Kov
In my ios app with new Xcode 11 GM Seed 2 after deploy, apple returned error: ITMS-90683: Missing Purpose String in Info.plistwith NSBluetoothAlwaysUsageDescription.
在我的 ios 应用程序中,部署后使用新的 Xcode 11 GM Seed 2,苹果返回错误: ITMS-90683:Info.plist 中缺少用途字符串,带有 NSBluetoothAlwaysUsageDescription。
The problem is that I don't use bluetooth in my app. Or maybe I don't know about it. How can I find out why this permission purpose is needed?
问题是我没有在我的应用程序中使用蓝牙。或者也许我不知道。我怎样才能找出为什么需要这个许可目的?
I'm not using CoreBluetooth.framework
我不使用 CoreBluetooth.framework
采纳答案by Maurice
I had this exact same issue today. When I did a grep search I found that there is some reference to CoreBluetooth.framework inside my project.pbxproj
我今天遇到了完全相同的问题。当我进行 grep 搜索时,我发现在我的 project.pbxproj 中有一些对 CoreBluetooth.framework 的引用
I removed the reference and building the app went fine. Uploaded to Apple and it got through so this worked for me.
我删除了引用并且构建应用程序很顺利。上传到 Apple,它通过了,所以这对我有用。
To search use the following command
要搜索使用以下命令
grep -r -a CoreBluetooth.framework ProjectFolder
回答by Chase Roberts
Open your Info.plist and add a NSBluetoothAlwaysUsageDescription
. You can do this in the editor by adding a line item like this:
打开您的 Info.plist 并添加一个NSBluetoothAlwaysUsageDescription
. 您可以在编辑器中通过添加这样的行项目来执行此操作:
Or you can right click on the Info.plist and Open As -> Source Code and paste in the two appropriate lines as xml:
或者,您可以右键单击 Info.plist 并打开为 -> 源代码,然后将两行粘贴为 xml:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
....
<key>NSBluetoothPeripheralUsageDescription</key>
<string>We use Bluetooth to connect to the MantisX hardware device.</string>
....
</dict>
</plist>
回答by John
I was able to snuff out CoreBluetooth usages by scanning for symbol usages, specifically looking for CBCentralManager
. The script I wrote to do so:
我能够通过扫描符号用法来扼杀 CoreBluetooth 用法,特别是寻找CBCentralManager
. 我为此编写的脚本:
#!/usr/bin/env bash
#
# find-bluetooth-usages.sh <app1.app> <app2.app> ...
check_references_corebluetooth() {
nm "" | grep "CBCentralManager" 2>&1 >/dev/null
}
find_usages () {
app_path=
if [[ ! -d $app_path || ! -d "$app_path/Frameworks" ]]; then
echo "$app_path is not a valid app directory."
exit 1
fi
app_filename=$(basename -- "$app_path")
app_name="${app_filename%.*}"
if check_references_corebluetooth "$app_path/$app_name"; then
echo "$app_name contains references to CoreBluetooth"
fi
for framework_filename in $(ls "$app_path/Frameworks" | egrep '\.framework$'); do
framework_path="$app_path/Frameworks/$framework_filename"
framework_name=$(basename "$framework_path" .framework)
if check_references_corebluetooth "$framework_path/$framework_name"; then
echo "$framework_name contains references to CoreBluetooth"
fi
done
}
for arg in "$@"; do
find_usages "$arg"
done
This will dig through the main binary + its included frameworks to find CBCentralManager
references. Ex:
这将挖掘主要二进制文件 + 其包含的框架以查找CBCentralManager
引用。前任:
./find-bluetooth-usages.sh /path/to/MyApp.app
./find-bluetooth-usages.sh /path/to/MyApp.app
回答by Deepak
A third party library/framework/pod in your app might be using CoreBluetooth. Just add NSBluetoothAlwaysUsageDescription
in your Info.plist, error will be gone.
您的应用程序中的第三方库/框架/pod 可能正在使用 CoreBluetooth。只需添加NSBluetoothAlwaysUsageDescription
您的 Info.plist,错误就会消失。
回答by vatsal tanna
If your app has a deployment target earlier than iOS 13, add the NSBluetoothPeripheralUsageDescription key to your app's Information Property List file in addition to NSBluetoothAlwaysUsageDescription key as one or more of third party in your project uses bluetooth functionality.
如果您的应用具有早于 iOS 13 的部署目标,除了 NSBluetoothAlwaysUsageDescription 键之外,还要将 NSBluetoothPeripheralUsageDescription 键添加到应用的信息属性列表文件中,因为您项目中的一个或多个第三方使用蓝牙功能。
回答by jolly
Apparently Apple has made some policy changes. Otherwise, it is weired to ask for non-used flags. It is very concerning. I also got my apps rejected for these reasons, all the while older versions are running without this.
显然,苹果已经做出了一些政策上的改变。否则,要求未使用的标志是很奇怪的。这是非常令人担忧的。由于这些原因,我的应用程序也被拒绝了,而旧版本在没有这个的情况下运行。
回答by Bane M
I've tried Maurice's answer, with and without .framework
extension, but did not find any reference to CoreBluetooth
in my project.
I also had previously in Info.plist
file added: "Privacy - Bluetooth Peripheral Usage Description
", with String Value: "App would like to use your bluetooth for communication purposes"
".
This didn't work either.
Finally after seeing Chase Roberts's answer I added: "NSBluetoothAlwaysUsageDescription
", with String value: "App would like to use your bluetooth for communication purposes
".
After that this error was not shown again for my app while publishing.
我已经尝试过 Maurice 的答案,无论是否有.framework
扩展名,但CoreBluetooth
在我的项目中没有找到任何参考。我之前也曾在Info.plist
文件中添加:“ Privacy - Bluetooth Peripheral Usage Description
”,字符串值:“ App would like to use your bluetooth for communication purposes"
”。这也不起作用。
最后在看到蔡斯罗伯茨的回答后,我添加了:“ NSBluetoothAlwaysUsageDescription
”,字符串值:“ App would like to use your bluetooth for communication purposes
”。之后,我的应用程序在发布时不再显示此错误。
Note:In warning for error: ITMS-90683
, for my app was said that delivery was successful, but I can if I wish to make changes in regard to stated issue.
注意:在错误警告中:ITMS-90683
,因为我的应用程序被告知交付成功,但如果我希望对所述问题进行更改,我可以。
回答by Marc
You should add both NSBluetoothPeripheralUsageDescription and NSBluetoothAlwaysUsageDescription to your Info.plist file. Your Info.plist file is located (by default) inside your prroject folder "Supporting Files" group and may be called something like {PROJECTNAME}-Info.plist. You have a couple of choices for adding it. One choice is to just editthe file from the command line using vim or whatever. Then add these lines:
您应该将 NSBluetoothPeripheralUsageDescription 和 NSBluetoothAlwaysUsageDescription 添加到您的 Info.plist 文件中。您的 Info.plist 文件(默认情况下)位于您的项目文件夹“支持文件”组中,可能会被称为 {PROJECTNAME}-Info.plist。您有多种选择来添加它。一种选择是使用 vim 或其他方式从命令行编辑文件。然后添加这些行:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App would like to use your bluetooth for communication purposes</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App would like to use your bluetooth for communication purposes</string>
The second choice is to double click that Info.plist file in XCode and use the "super helpful" XCode editor. This annoying editor does not actually have the NSBluetoothAlwaysUsageDescription in a dropdown list, you have to add it manually. Super helpful. Anyway there is a little plus button to the right of the Information Property List header, just click that. In step 1 you look for "Privacy - Bluetooth Peripheral Usage Description". That is the readable name for NSBluetoothPeripheralUsageDescription. Then just click on the value part at the right and enter your text, like "App would like to use your bluetooth for communication purposes" or watever. Once that is done, click that same plus button again and you will get the same drpdown list. Ignore that list and just paste the string NSBluetoothAlwaysUsageDescription there. Then click on the value to the right and paste "App would like to use your bluetooth for communication purposes".
第二种选择是在 XCode 中双击该 Info.plist 文件并使用“超级有用”的 XCode 编辑器。这个烦人的编辑器实际上没有下拉列表中的 NSBluetoothAlwaysUsageDescription,您必须手动添加它。超级有帮助。无论如何,信息属性列表标题右侧有一个加号按钮,只需单击它。在第 1 步中,您会查找“隐私 - 蓝牙外围设备使用说明”。这是 NSBluetoothPeripheralUsageDescription 的可读名称。然后只需单击右侧的值部分并输入您的文本,例如“应用程序希望将您的蓝牙用于通信目的”或水。完成后,再次单击相同的加号按钮,您将获得相同的下拉列表。忽略该列表并将字符串 NSBluetoothAlwaysUsageDescription 粘贴到那里。然后单击右侧的值并粘贴“应用程序希望将您的蓝牙用于通信目的”。
回答by Shakeel Ahmed
Swift 5
斯威夫特 5
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App would like to use your bluetooth for communication purposes</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App would like to use your bluetooth for communication purposes</string>
回答by ysnzlcn
In my case, I wasn't using any bluetooth related API but app was crashing because of this. And I found out that Google Mobile Ads was using bluetooth. I made sure of this by removing it from pods and rerunning the app. (I think we all should ask Google to why they need bluetooth to show mobile ads)
就我而言,我没有使用任何与蓝牙相关的 API,但应用程序因此崩溃。我发现 Google 移动广告正在使用蓝牙。我通过从 pod 中删除它并重新运行应用程序来确保这一点。(我认为我们都应该问 Google 为什么他们需要蓝牙来展示移动广告)
Anyways, you can stop your app from crashing by adding NSBluetoothAlwaysUsageDescription
to your plist for now.
无论如何,您现在可以通过添加NSBluetoothAlwaysUsageDescription
到您的 plist来阻止您的应用程序崩溃。