iOS 16.4 Web Inspector 无法 debug 网页

420 阅读1分钟

最近在 debug 自己 app 内的 WKWebView 时发现突然挂不上调试器了, 但是 Safari 内打开的网页却是正常可以使用的. 最后在今年 WWDC 的一段 session 里发现需要手动将 WebView.isInspectable修改为 true.

CleanShot2023-09-07at17.54.03@2x

可以发现这个特性是在 iOS 16.4, macOS 13.3 以及 tvOS 16.4 时加上的.

Your app may use web content for part of its user interface, or you may use JavaScript to control parts of your app. In these cases, there is API available in macOS 13.3 and later, iOS and iPadOS 16.4 and later, and xrOS to enable inspection of content in your apps.

有趣的是, 可以看到这里苹果在录制这段 session 的时候内部还是使用 xrOS 来称呼现在的 visionOS. 看来苹果因为泄露名字的原因在发布会前连夜修改了叫法.


Rediscover Safari developer features