简体   繁体   English

如何使用Safari在Mac应用程序中调试WKWebView?

[英]How can I use Safari to debug a WKWebView in my Mac app?

I'm developing a Mac app that uses WKWebView to display HTML resources. 我正在开发一个使用WKWebView来显示HTML资源的Mac应用程序。 I want to use the Safari inspector to debug the JavaScript in my app. 我想使用Safari检查器在我的应用程序中调试JavaScript。

When I debug my app by launching it from Xcode, Safari doesn't show my app in the Develop menu — it displays "No Inspectable Applications". 当我通过从Xcode启动应用程序来调试我的应用程序时,Safari不会在“开发”菜单中显示我的应用程序-它显示“无检查应用程序”。

How do I get my Mac app to appear in Safari's Develop menu? 如何使Mac应用程序出现在Safari的“开发”菜单中?

From https://forums.developer.apple.com/thread/21521 : https://forums.developer.apple.com/thread/21521

Add an entitlement file to the application, then set the entitlement key com.apple.security.get-task-allow to YES. 将权利文件添加到应用程序,然后将权利密钥com.apple.security.get-task-allow为YES。 This key is automatically added to iOS applications for Xcode debugging, but it must be added manually to Mac applications. 该密钥会自动添加到iOS应用程序中以进行Xcode调试,但必须手动将其添加到Mac应用程序中。

If you only want to use Safari to inspect while Xcode is running a debug build, add the entitlement file to a Debug configuration and not the Release configuration. 如果您只想在Xcode运行调试版本时使用Safari进行检查,请将授权文件添加到Debug配置中,而不是Release版本中。

Download & try same in Safari Technology Preview 下载并在Safari技术预览版中尝试相同的操作

https://developer.apple.com/safari/technology-preview/ https://developer.apple.com/safari/technology-preview/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM