NSBluetoothAlwaysUsageDescription required, but bluetooth is not used

前端 未结 10 1830
青春惊慌失措
青春惊慌失措 2021-01-01 18:28

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 NSBluetoothAlwaysUsageDe

相关标签:
10条回答
  • 2021-01-01 19:07

    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)

    Anyways, you can stop your app from crashing by adding NSBluetoothAlwaysUsageDescription to your plist for now.

    0 讨论(0)
  • 2021-01-01 19:09

    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.

    0 讨论(0)
  • 2021-01-01 19:11

    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
    
    0 讨论(0)
  • 2021-01-01 19:13

    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

    0 讨论(0)
  • 2021-01-01 19:13

    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.

    0 讨论(0)
  • 2021-01-01 19:20

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

    0 讨论(0)
提交回复
热议问题