Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App discovers bluetooth devices only when ran from Xcode

I'm working with a fork of this project for Empatica E4 wristbands and I'm unable to make the discover devices work without running the app from Xcode. The situation can be replicated with the original sample project.

When I ran the project through Xcode, I can see the list of nearby devices. However, when I close the app and ran in from the phone (instead of clicking "play" on Xcode), I can't see any device.

Should I configure something on the Project or own a developer account? Right now I'm not paying a developer account but I thought I could do this without using Xcode to run the app. Thanks.

In short: I can open the app without connecting the phone to XCode but I can't discover devices when I'm not connected to XCode.

More details. When executed through Xcode on the iphone, the device discover works. On the logs, we can see:

E4tester    [didUpdate] status 2 • kBLEStatusScanning
bluetoothd  Received XPC message "CBMsgIdScan" from session "Empatica.E4testerCV-central-313-24"
bluetoothd  Received 'start scan' request without duplicates for all UUIDs from session "Empatica.E4testerCV-central-313-24"
bluetoothd  State of application "Empatica.E4testerCV" is now "foreground-running"

However. When the app is opened on the iPhone (instead of ran via Xcode), we get the following log messages:

E4tester    [didUpdate] status 0 • kBLEStatusNotAvailable
E4tester    Task <EA813C26-F662-461C-8C47-A97FA7E32BA4>.<0> response ended
E4tester    Task <EA813C26-F662-461C-8C47-A97FA7E32BA4>.<0> done using Connection 1

The important detail here is the kBLEStatusNotAvailable status, which contrasts with kBLEStatusScanning. According to their docs this means The iOS device does not support Bluetooth LE, or the Bluetooth LE module is not active. but the device does support BT LE and is enabled.

I opened an issue on their repository.

like image 898
Carlos Vega Avatar asked May 13 '19 10:05

Carlos Vega


2 Answers

You need developer's account for testing Xcode apps in devices.

Developer account will give certificates and provisioning to run app in device. There is 2 certificates develop and distribution.

In your case you don't have any apple account. so maybe u are using freee provisioning

Please read this one to understand free provision: Test iOS app on device without apple developer program or jailbreak

Maybe the capabilites on free provision is limited on debug mode *(runned from xcode)

like image 173
antonio yaphiar Avatar answered Nov 04 '22 06:11

antonio yaphiar


In the end I got a direct answer from Empatica support team which I think is perfect since I sought an answer from credible and/or official sources.

Still, I would like to thank Antonio for his useful answer as well as Scriptable and Hichem for their messages.

The answer from Empatica E4 team is the following:

@carlosvega If you are working with an iPhone with iOS 11 or 12 you should add the string NSBluetoothPeripheralUsageDescription in the Info.plist file. The sample code has been created a while ago before the privacy string was mandatory. -- Empatica Engineering Team

like image 44
Carlos Vega Avatar answered Nov 04 '22 06:11

Carlos Vega