Demo apps with Swift 3 not working

  1. Has anyone been able to get these to work in Xcode 8 GM and IOS 10? I’m unable to get one of the demo apps to work. Some just don’t function after conversion.

  2. Running the Estimote app on IOS 10 does not talk to the cloud even if says its ‘synced’. The beacons seem updated but the cloud still says ‘pending’. which one to trust?

any workarounds for these?

UPDATE: actually, I just discovered that changing:

func beaconManager(_ manager: AnyObject, didRangeBeacons beacons: [CLBeacon], 
    inRegion region: CLBeaconRegion) {

to:

func beaconManager(_ manager: Any, didRangeBeacons beacons: [CLBeacon], 
    inRegion region: CLBeaconRegion) {

(i.e., AnyObject to Any)

… fixes the problem for me (:


Original post:

According to my current understanding of things, there’s this weird problem with Swift 3 and Obj-C frameworks (like Estimote SDK), because Swift 3 imports the methods under new names.

Let’s take the beaconManager:didRangeBeacons:inRegion: delegate method. It used to be imported like this:

func beaconManager(_ manager: AnyObject, didRangeBeacons beacons: [CLBeacon], 
    inRegion region: CLBeaconRegion) {

In Swift 3, because they wanted to “beautify” the APIs imported from Obj-C, it’s imported like this:

func beaconManager(_ manager: AnyObject, didRangeBeacons beacons: [CLBeacon], 
    in region: CLBeaconRegion) {

Note that the last part is now in region, not inRegion region. But the side-effect is, that this changes the Obj-C symbol to beaconManager:didRangeBeacons:in: … but the SDK still expects beaconManager:didRangeBeacons:inRegion::exclamation:

In my own app, I fixed that by making the ranging delegate method look like this:

@objc(beaconManager:didRangeBeacons:inRegion:)
func beaconManager(_ manager: AnyObject, didRangeBeacons beacons: [CLBeacon], 
    in region: CLBeaconRegion) {

i.e., I added the explicit @objc statement, to force to export this method under the old name.

We’ll soon be updating our demoes to Swift 3, and we’re also looking for ways to fix this problem directly in the SDK, if possible.