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