Get the currently connected WiFi informations in Swift 4.x

i0S Swift Issue

While developing applications many times you need to get the connection information of Wifi or Access Point to serve many different purposes. The following guide will help you get the SSID, BSSID (MAC Address) and Interface Name information of Wifi or Access Point that your iOS device is connected to them.

First, You must turn on “Access WiFi Information” from Xcode’s “Capabilities

Turn On "Access WiFi Information" from Xcode's "Capabilities"
Turn On “Access WiFi Information” from Xcode’s “Capabilities”

The following code will return an array containing Wifi information including SSID, BSSID (MAC) and Interface Name:

Use print(getWifiInfo()) to view logs, like this:

(TODO)

Or when you just want to get the SSID of Wifi or Access Point, you can use the following short code: