How to automatically reset iPhone simulator on build

早过忘川 提交于 2019-12-21 05:37:16

问题


After moving several JSON files from the app bundle root to within a directory structure (also in the app bundle) the app kept running as if the files remained in their prior location. After much head scratching and doing a clean build I remembered that the iPhone simulator had to be cleared out in order to get rid of these files in the old locations.

It'd sure be nice to have the option to force a reset of the simulator on every build. Clean-slate mode, if you will. Can this be hacked in any way? Any ideas?


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/9966288/how-to-automatically-reset-iphone-simulator-on-build

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