They used to have some additional measures to find out the distance. As noticed by hotpaw2 in comments
Quick Answer - Swift 4.2
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
if let power = advertisementData[CBAdvertisementDataTxPowerLevelKey] as? Double{
print("Distance is ", pow(10, ((power - Double(truncating: RSSI))/20)))
}
}
TL:DR;
Factors Affecting RSSI
RSSI readings are not very stable and highly depend on environment
It may also vary due to a number of factors, including both the power and sensitivity of the sensing / transmitting radios, as well as the environmental stuff (are you inside, outside? are there many people nearby? noisy wireless environment or not, and so on).
The problem, however, is that beacon signals are actually radio waves, and can be absorbed by metals, walls, water etc. Since they transmit radio signals in the commonly used 2.4GHz band, the signal strength received from a beacon varies widely because of interference.
One of the mostly used formula to find out distance is
d = 10 ^ ((TxPower - RSSI) / 20)
TxPower is typically known as transmit power
How to get TxPower From BLE advertisement Data
The txPower value will be available in BLE advertisement data (available only if the broadcaster (peripheral) provides its Tx power level).
As per apple documentation the value of CBAdvertisementDataTxPowerLevelKey in CBAdvertisementDataTx
Delegate method to access the raw advertisement data
optional func centralManager(_ central: CBCentralManager,
didDiscover peripheral: CBPeripheral,
advertisementData: [String : Any],
rssi RSSI: NSNumber)
Can be also accessed by using BlueCap API
To know more advantages of AirPlay than Classical Bluetooth
https://www.cambridgeaudio.com/blog/airplay
RSSI and Distance
According to the image below from Link

RSSI will go down if you cover the beacon (e.g., a person comes in between you and the beacon). That is, you're still in the same distance, but RSSI goes down—so where you to base the distance estimate on the RSSI, the distance would go up, without you moving an inch.
Many of the above explanations are taken from other sites.
I Hope it sum up to your need!