今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

iOS 16.4 Webview cannot be debugged using Safari.

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.

Reference#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.