How to automatically reset iPhone simulator on build

南笙酒味 提交于 2019-12-03 17:16:32
Vic

You can add a "New Run Script Action" to the "Pre-actions" for the "Run" step of your scheme to run AppleScript that will reset the simulator.

First set the shell to /usr/bin/osascript

Then enter the following in the "type a script" area:

#!/usr/bin/env osascript

tell application "iPhone Simulator"
    activate
end tell

tell application "System Events"
    tell process "iPhone Simulator"
        tell menu bar 1
            tell menu bar item "iOs Simulator"
                tell menu "iOs Simulator"
                    click menu item "Reset Content and Settings…"
                end tell
            end tell
        end tell
        tell window 1
            click button "Reset"
        end tell
    end tell
end tell

In Yosemite + iOS Simulator 8.3, It worked when I changed the Vic's strings of "iPhone Simulator" and "iOs Simulator" to "iOS Simulator".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!