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.
重要描述
在iOS 12+中使用此方法需要在Xcode中為應用授權獲取WiFi資訊的能力。授權後,Xcode會自動在App ID和應用的許可權列表中增加獲取WiFi資訊的許可權。
看到這裡,解決方案就有了:Xcode -> [Project Name] -> Targets -> [Target Name] -> Capabilities -> Access WiFi Information -> ON