iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iPhone模拟器启动时自动打开Safari Debugger大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

Safari中的iOS网页调试器是蜜蜂的膝盖,但每次重启模拟器时都会关闭。每次构建后,不仅可以从菜单中重新打开它,而且还可以调试启动过程中发生的任何行为。 有没有办法在xcode中设置一个触发器,以便在每次构建之后自动打开Safari调试器,或者可能是构建sHell脚本或Automator操作来构建并立即打开调试器的方法? 这是一个部分解决方案。这将打开一个Safari的调试窗口,这是一个很好的,
Safari中的iOS网页调试器是蜜蜂的膝盖,但每次重启模拟器时都会关闭。每次构建后,不仅可以从菜单中重新打开它,而且还可以调试启动过程中发生的任何行为。

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

解决方法

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

在Mac上打开脚本编辑器(命令空间栏并键入脚本编辑器)

粘贴在此代码中:

-- `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"})

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

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

大佬总结

以上是大佬教程为你收集整理的iPhone模拟器启动时自动打开Safari Debugger全部内容,希望文章能够帮你解决iPhone模拟器启动时自动打开Safari Debugger所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。