启动iPhone模拟器时自动打开Safari调试器

Luk*_*nis 19 iphone safari xcode automator

Safari中的iOS Web调试器是蜜蜂的膝盖,但每次重启模拟器时它都会关闭.在每次构建之后,不仅从菜单中重新打开它很烦人,而且调试启动期间发生的任何行为都很棘手.

有没有办法在Xcode中设置一个触发器,以便在每次构建后自动打开Safari调试器,或者可能是构建shell脚本或Automator操作以进行构建并立即打开调试器的方法?

Dev*_*v01 10

这是部分解决方案.这将打开Safari的调试窗口,只需单击一下即可,但不是自动的.

Script Editor在Mac上打开(Command + Space Bar并输入脚本编辑器)

粘贴此代码:

-- `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", "Simulator", "index.html"})
Run Code Online (Sandbox Code Playgroud)

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

(可选)您可以将脚本保存为应用程序,这样就不必打开脚本编辑器.

  • 我改进了@TomKrones代码,因此您不必指定`index.html`条目.我的建议是将脚本保存为应用程序,将其放在Dock中,然后在需要时单击它.要点:https://gist.github.com/toioski/44abee301719d090808727d46c0567bc (2认同)