1

This question is related to my earlier question How to Debug Javascript in IOS Action App Extension. Basically, I am developing an mobile safari extension, and part of the work is to develop a javascript (operating on top of "document" provided by mobile safari) to run inside the app extension.

However, I have not found a way to debug a javascript file inside an app extension. Now, I am trying to ask the question a bit differently - given mobile safari on a page, can I somehow run an external javascript on that page and debug this external javascript? I suppose that Safari Web Inspector could help with that? Thanks.

4

1 回答 1

0

(这是您其他问题的略微定制的答案)

官方文档是[这里][1]。

这并不难,尽管最近我在连接到 iOS 模拟器时遇到了页面显示的问题。在那种情况下,我最终直接使用我的手机。(显然您需要在 iOS 模拟器开始检查“远程”模拟器会话后启动桌面 Safari)

  • 确保在设备Settings->Safari->Advanced->Web Inspector上打开。
  • (确保您已从设备信任计算机)
  • 在您的设备上启动 MobileSafari。
  • 在桌面上启动 Safari,确保Show Develop menu in menu barPreferences.
  • Develop菜单中,您将看到您的设备名称,例如“BSharer 的 iPhone”。
  • 选择设备名称下方的页面名称,例如“en.m.wikipedia.org - Wikipedia”。

您现在正在桌面上调试该设备的页面。开发人员页面将打开,您可以像在台式机上运行一样进行调试。您现在应该看到该页面可用的所有 JavaScript 并设置断点。

(应用扩展需要该debugger;语句,因为我们没有看到应用扩展注入的 javascript 文件。您仍然可以使用该debugger语句,但通常不需要。)

于 2017-02-26T02:43:37.843 回答