gpt4 book ai didi

ios6 - 当iOS模拟器启动时,是否可以自动加载Web Inspector?

转载 作者:行者123 更新时间:2023-12-03 09:12:46 29 4
gpt4 key购买 nike

我将iOS 6模拟器与Safari中崭新的Web Inspector结合使用。

问题:可以在加载iOS 6 Web应用程序时自动加载Web检查器吗?

我正在使用PhoneGap / Cordova,并且在启动时加载了很多JavaScript。我广泛使用console.log()进行调试,并希望在应用程序启动后加载Web Inspector。

目前,当我点击“在Xcode上运行”时,该应用会加载并在我的第一个函数上添加setTimeout,这样我就可以跳至Safari并将Web Inspector附加在该页面上。

我更希望删除此步骤并添加一个自动化步骤,该步骤将直接加载Web Inspector。

还有其他解决方案吗?

最佳答案

这是部分解决方案。一键打开Safari的调试窗口,这会好很多,但不是自动的。

在Mac上打开Script Editor(命令+空格键,然后在脚本编辑器中键入)

粘贴此代码:

-- `menu_click`, by Jacob Rus, September 2006
--
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item. In this case, assuming the Finder
-- is the active application, arranging the frontmost folder by date.

on menu_click(mList)
local appName, topMenu, r

-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"

-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)

-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click

on menu_click_recurse(mList, parentObject)
local f, r

-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)

-- either actually click the menu item, or recurse again
tell application "System Events"
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse

menu_click({"Safari", "Develop", "IOS Simulator", "index.html"})

模拟器打开后,在脚本上单击“运行”(您可能需要首次允许设置中的脚本编辑器)。

(可选)您可以将脚本另存为应用程序,从而不必打开脚本编辑器。

(此答案是Galatin先前答案的详细版本)

关于ios6 - 当iOS模拟器启动时,是否可以自动加载Web Inspector?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13073496/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com