NSBluetoothAlwaysUsageDescription required, but bluetooth is not used
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
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>
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