NSBluetoothAlwaysUsageDescription required, but bl

2020-02-27 19:05发布

问题:

In my ios app with new Xcode 11 GM Seed 2 after deploy, apple returned error: ITMS-90683: Missing Purpose String in Info.plist with NSBluetoothAlwaysUsageDescription.

https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothalwaysusagedescription?language=objc readed.

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

回答1:

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

I removed the reference and building the app went fine. Uploaded to Apple and it got through so this worked for me.

To search use the following command

grep -r -a CoreBluetooth.framework ProjectFolder


回答2:

Open your Info.plist and add a NSBluetoothAlwaysUsageDescription. You can do this in the editor by adding a line item like this:

Or you can right click on the Info.plist and Open As -> Source Code and paste in the two appropriate lines as 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>


回答3:

A third party library/framework/pod in your app might be using CoreBluetooth. Just add NSBluetoothAlwaysUsageDescription in your Info.plist, error will be gone.



回答4:

I was able to snuff out CoreBluetooth usages by scanning for symbol usages, specifically looking for CBCentralManager. The script I wrote to do so:

#!/usr/bin/env bash
#
# find-bluetooth-usages.sh <app1.app> <app2.app> ...

check_references_corebluetooth() {
  nm "$1" | grep "CBCentralManager" 2>&1 >/dev/null
}

find_usages () {
  app_path=$1
  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:

./find-bluetooth-usages.sh /path/to/MyApp.app



回答5:

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.



回答6:

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.



回答7:

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.

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.



回答8:

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:

<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".