title: iOS 16.4 Webview cannot be debugged with Safari
tags:
- Technology
- iOS
date: 2023-04-14 15:00#
Background#
After upgrading Xcode to 14.3, the simulator is iOS 16.4. I wanted to use Safari -> Developer -> Web Inspector to debug, but found that it couldn't be accessed.
Solution#
At first, I thought it might be because the Advanced setting in Safari was not enabled. After checking, I found that the switch was already turned on.
After searching, I found that starting from iOS 16.4, if you want to use Web Inspector, you need to add the following code:
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
After setting this, run the app again and use Safari to inspect, and you will be able to see it.