问题前提:
iOS12中,通过CNCopyCurrentNetworkInfo来获取WIFI的SSID,结果发现内容为空,取得失败。
问题解决:
对于CNCopyCurrentNetworkInfo,苹果开发者网站给出如下贴士。
Important
To use this function in iOS 12 and later, enable the Access WiFi Information capability for your app in Xcode. When you enable this capability, Xcode automatically adds the Access WiFi Information entitlement to your entitlements file and App ID.
因此解决办法就是将Xcode的Access WIFI勾选后可以解决此问题。